Skip to content

Commit 92945a9

Browse files
mvedma0405alexs-mparticle
authored andcommitted
fix: adds native collection of snap click ID (#989)
1 parent 49202b3 commit 92945a9

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

src/integrationCapture.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ const integrationMapping: IntegrationIdMapping = {
125125
mappedKey: 'tiktok_cookie_id',
126126
output: IntegrationOutputs.PARTNER_IDENTITIES,
127127
},
128+
129+
// Snapchat
130+
// https://businesshelp.snapchat.com/s/article/troubleshooting-click-id?language=en_US
131+
ScCid: {
132+
mappedKey: 'SnapchatConversions.ClickId',
133+
output: IntegrationOutputs.CUSTOM_FLAGS,
134+
},
128135
};
129136

130137
export default class IntegrationCapture {

test/jest/integration-capture.spec.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ describe('Integration Capture', () => {
2727
'gbraid',
2828
'wbraid',
2929
'ttclid',
30+
'ScCid'
3031
]);
3132
});
3233

@@ -79,6 +80,7 @@ describe('Integration Capture', () => {
7980
'gbraid=67890',
8081
'wbraid=09876',
8182
'rtid=84324',
83+
'ScCid=1234'
8284
].join('&');
8385

8486
const url = new URL(`https://www.example.com/?${queryParams}`);
@@ -101,6 +103,7 @@ describe('Integration Capture', () => {
101103
gbraid: '67890',
102104
rtid: '84324',
103105
wbraid: '09876',
106+
ScCid:'1234'
104107
});
105108
});
106109

@@ -122,6 +125,22 @@ describe('Integration Capture', () => {
122125
});
123126
});
124127

128+
describe('SnapChat Click Ids', () => {
129+
it('should capture Snapchat specific click ids', () => {
130+
const url = new URL('https://www.example.com/?ScCid=1234');
131+
132+
window.location.href = url.href;
133+
window.location.search = url.search;
134+
135+
const integrationCapture = new IntegrationCapture();
136+
integrationCapture.capture();
137+
138+
expect(integrationCapture.clickIds).toEqual({
139+
ScCid: '1234',
140+
});
141+
});
142+
});
143+
125144
describe('Facebook Click Ids', () => {
126145
it('should format fbclid correctly', () => {
127146
jest.spyOn(Date, 'now').mockImplementation(() => 42);

test/src/tests-integration-capture.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ describe('Integration Capture', () => {
5151
gbraid: '6574',
5252
rtid: '45670808',
5353
wbraid: '1234111',
54+
ScCid: '1234',
5455
});
5556

5657
mParticle.init(apiKey, window.mParticle.config);
@@ -85,6 +86,7 @@ describe('Integration Capture', () => {
8586
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gclid'], 'Google Enhanced Conversions Gclid').to.equal('234');
8687
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gbraid'], 'Google Enhanced Conversions Gbraid').to.equal('6574');
8788
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Wbraid'], 'Google Enhanced Conversions Wbraid').to.equal('1234111');
89+
expect(testEvent.data.custom_flags['SnapchatConversions.ClickId'], 'Snapchat Click ID').to.equal('1234');
8890
});
8991

9092
it('should add captured integrations to event custom flags, prioritizing passed in custom flags', async () => {
@@ -107,6 +109,7 @@ describe('Integration Capture', () => {
107109
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gclid'], 'Google Enhanced Conversions Gclid').to.equal('234');
108110
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gbraid'], 'Google Enhanced Conversions Gbraid').to.equal('6574');
109111
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Wbraid'], 'Google Enhanced Conversions Wbraid').to.equal('1234111');
112+
expect(testEvent.data.custom_flags['SnapchatConversions.ClickId'], 'Snapchat Click ID').to.equal('1234');
110113
});
111114

112115
it('should add captured integrations to page view custom flags', async () => {
@@ -130,6 +133,7 @@ describe('Integration Capture', () => {
130133
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gclid'], 'Google Enhanced Conversions Gclid').to.equal('234');
131134
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gbraid'], 'Google Enhanced Conversions Gbraid').to.equal('6574');
132135
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Wbraid'], 'Google Enhanced Conversions Wbraid').to.equal('1234111');
136+
expect(testEvent.data.custom_flags['SnapchatConversions.ClickId'], 'Snapchat Click ID').to.equal('1234');
133137
});
134138

135139
it('should add captured integrations to page view custom flags, prioritizing passed in custom flags', async () => {
@@ -151,6 +155,7 @@ describe('Integration Capture', () => {
151155
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gclid'], 'Google Enhanced Conversions Gclid').to.equal('234');
152156
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gbraid'], 'Google Enhanced Conversions Gbraid').to.equal('6574');
153157
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Wbraid'], 'Google Enhanced Conversions Wbraid').to.equal('1234111');
158+
expect(testEvent.data.custom_flags['SnapchatConversions.ClickId'], 'Snapchat Click ID').to.equal('1234');
154159
});
155160

156161
it('should add captured integrations to commerce event custom flags', async () => {
@@ -188,6 +193,7 @@ describe('Integration Capture', () => {
188193
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gclid'], 'Google Enhanced Conversions Gclid').to.equal('234');
189194
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gbraid'], 'Google Enhanced Conversions Gbraid').to.equal('6574');
190195
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Wbraid'], 'Google Enhanced Conversions Wbraid').to.equal('1234111');
196+
expect(testEvent.data.custom_flags['SnapchatConversions.ClickId'], 'Snapchat Click ID').to.equal('1234');
191197
});
192198

193199
it('should add captured integrations to commerce event custom flags, prioritizing passed in flags', async () => {
@@ -225,6 +231,7 @@ describe('Integration Capture', () => {
225231
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gclid'], 'Google Enhanced Conversions Gclid').to.equal('234');
226232
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gbraid'], 'Google Enhanced Conversions Gbraid').to.equal('6574');
227233
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Wbraid'], 'Google Enhanced Conversions Wbraid').to.equal('1234111');
234+
expect(testEvent.data.custom_flags['SnapchatConversions.ClickId'], 'Snapchat Click ID').to.equal('1234');
228235
});
229236

230237
it('should add captured integrations to commerce event custom flags', async () => {
@@ -262,6 +269,7 @@ describe('Integration Capture', () => {
262269
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gclid'], 'Google Enhanced Conversions Gclid').to.equal('234');
263270
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gbraid'], 'Google Enhanced Conversions Gbraid').to.equal('6574');
264271
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Wbraid'], 'Google Enhanced Conversions Wbraid').to.equal('1234111');
272+
expect(testEvent.data.custom_flags['SnapchatConversions.ClickId'], 'Snapchat Click ID').to.equal('1234');
265273
});
266274

267275
it('should add captured integrations to commerce event custom flags, prioritizing passed in flags', async () => {
@@ -299,6 +307,7 @@ describe('Integration Capture', () => {
299307
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gclid'], 'Google Enhanced Conversions Gclid').to.equal('234');
300308
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Gbraid'], 'Google Enhanced Conversions Gbraid').to.equal('6574');
301309
expect(testEvent.data.custom_flags['GoogleEnhancedConversions.Wbraid'], 'Google Enhanced Conversions Wbraid').to.equal('1234111');
310+
expect(testEvent.data.custom_flags['SnapchatConversions.ClickId'], 'Snapchat Click ID').to.equal('1234');
302311
});
303312

304313
it('should add captured integrations to batch as partner identities', async () => {

0 commit comments

Comments
 (0)