@mparticle/web-adwords-kit 2.3.2 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,682 +17,823 @@ Object.defineProperty(exports, '__esModule', { value: true });
17
17
  // See the License for the specific language governing permissions and
18
18
  // limitations under the License.
19
19
 
20
- var name = 'GoogleAdWords',
21
- moduleId = 82,
22
- MessageType = {
23
- SessionStart: 1,
24
- SessionEnd: 2,
25
- PageView: 3,
26
- PageEvent: 4,
27
- CrashReport: 5,
28
- OptOut: 6,
29
- Commerce: 16
30
- },
31
- ENHANCED_CONVERSION_DATA = "GoogleAds.ECData";
32
-
33
- // Declares valid Google consent values
34
- var googleConsentValues = {
35
- // Server Integration uses 'Unspecified' as a value when the setting is 'not set'.
36
- // However, this is not used by Google's Web SDK. We are referencing it here as a comment
37
- // as a record of this distinction and for posterity.
38
- // If Google ever adds this for web, the line can just be uncommented to support this.
39
- //
40
- // Docs:
41
- // Web: https://developers.google.com/tag-platform/gtagjs/reference#consent
42
- // S2S: https://developers.google.com/google-ads/api/reference/rpc/v15/ConsentStatusEnum.ConsentStatus
43
- //
44
- // Unspecified: 'unspecified',
45
- Denied: 'denied',
46
- Granted: 'granted',
47
- };
48
-
49
- // Declares list of valid Google Consent Properties
50
- var googleConsentProperties = [
51
- 'ad_storage',
52
- 'ad_user_data',
53
- 'ad_personalization',
54
- 'analytics_storage',
55
- ];
56
-
57
- var constructor = function () {
58
- var self = this,
59
- isInitialized = false,
60
- forwarderSettings,
61
- labels,
62
- customAttributeMappings,
63
- consentMappings = [],
64
- consentPayloadDefaults = {},
65
- consentPayloadAsString = '',
66
- reportingService,
67
- eventQueue = [],
68
- gtagSiteId;
69
-
70
- self.name = name;
71
-
72
- function processEvent(event) {
73
- var reportEvent = false;
74
- var sendEventFunction = function() {};
75
- var generateEventFunction = function () {};
76
- var conversionLabel;
77
- var eventPayload;
78
-
79
- if (isInitialized) {
80
- // First, process anything in the queue
81
- processQueue(eventQueue);
20
+ var name = 'GoogleAdWords',
21
+ moduleId = 82,
22
+ MessageType = {
23
+ SessionStart: 1,
24
+ SessionEnd: 2,
25
+ PageView: 3,
26
+ PageEvent: 4,
27
+ CrashReport: 5,
28
+ OptOut: 6,
29
+ Commerce: 16,
30
+ },
31
+ ENHANCED_CONVERSION_DATA = 'GoogleAds.ECData';
32
+
33
+ // Declares valid Google consent values
34
+ var googleConsentValues = {
35
+ // Server Integration uses 'Unspecified' as a value when the setting is 'not set'.
36
+ // However, this is not used by Google's Web SDK. We are referencing it here as a comment
37
+ // as a record of this distinction and for posterity.
38
+ // If Google ever adds this for web, the line can just be uncommented to support this.
39
+ //
40
+ // Docs:
41
+ // Web: https://developers.google.com/tag-platform/gtagjs/reference#consent
42
+ // S2S: https://developers.google.com/google-ads/api/reference/rpc/v15/ConsentStatusEnum.ConsentStatus
43
+ //
44
+ // Unspecified: 'unspecified',
45
+ Denied: 'denied',
46
+ Granted: 'granted',
47
+ };
48
+
49
+ // Declares list of valid Google Consent Properties
50
+ var googleConsentProperties = [
51
+ 'ad_storage',
52
+ 'ad_user_data',
53
+ 'ad_personalization',
54
+ 'analytics_storage',
55
+ ];
56
+
57
+ var constructor = function() {
58
+ var self = this,
59
+ isInitialized = false,
60
+ forwarderSettings,
61
+ labels,
62
+ customAttributeMappings,
63
+ consentMappings = [],
64
+ consentPayloadDefaults = {},
65
+ consentPayloadAsString = '',
66
+ reportingService,
67
+ eventQueue = [],
68
+ gtagSiteId;
69
+
70
+ self.name = name;
71
+
72
+ function processEvent(event) {
73
+ var reportEvent = false;
74
+ var sendEventFunction = function() {};
75
+ var generateEventFunction = function() {};
76
+ var conversionLabel;
77
+ var eventPayload;
78
+
79
+ if (isInitialized) {
80
+ // First, process anything in the queue
81
+ processQueue(eventQueue);
82
82
 
83
- try {
84
- if (window.gtag && forwarderSettings.enableGtag == 'True') {
85
- // If consent payload is empty,
86
- // we never sent an initial default consent state
87
- // so we shouldn't send an update.
88
- var eventConsentState = getEventConsentState(event.ConsentState);
89
- maybeSendConsentUpdateToGoogle(eventConsentState);
90
-
91
- if (
92
- forwarderSettings.enableEnhancedConversions ===
93
- 'True' &&
94
- hasEnhancedConversionData(event.CustomFlags)
95
- ) {
96
- window.enhanced_conversion_data =
97
- parseEnhancedConversionData(
98
- event.CustomFlags[ENHANCED_CONVERSION_DATA]
99
- );
100
- }
101
-
102
- sendEventFunction = sendGtagEvent;
103
- generateEventFunction = generateGtagEvent;
104
- generateCommerceEvent = generateGtagCommerceEvent;
105
-
106
- } else if (window.google_trackConversion) {
107
- // window.google_trackConversion is a legacy API and will be deprecated
108
- sendEventFunction = sendAdwordsEvent;
109
- generateEventFunction = generateAdwordsEvent;
110
- generateCommerceEvent = generateAdwordsCommerceEvent;
111
-
112
- } else {
113
- eventQueue.push({
114
- action: processEvent,
115
- data: event
116
- });
117
-
118
- return 'Can\'t send to forwarder ' + name + ', not initialized. Event added to queue.';
83
+ try {
84
+ if (window.gtag && forwarderSettings.enableGtag == 'True') {
85
+ // If consent payload is empty,
86
+ // we never sent an initial default consent state
87
+ // so we shouldn't send an update.
88
+ var eventConsentState = getEventConsentState(
89
+ event.ConsentState
90
+ );
91
+ maybeSendConsentUpdateToGoogle(eventConsentState);
92
+
93
+ if (
94
+ forwarderSettings.enableEnhancedConversions ===
95
+ 'True' &&
96
+ hasEnhancedConversionData(event.CustomFlags)
97
+ ) {
98
+ window.enhanced_conversion_data = parseEnhancedConversionData(
99
+ event.CustomFlags[ENHANCED_CONVERSION_DATA]
100
+ );
119
101
  }
120
102
 
121
- // Get conversionLabel to be used for event generation
122
- var conversionLabel = getConversionLabel(event);
123
- var customProps = getCustomProps(event);
124
-
125
- if (conversionLabel) {
126
- // Determines the proper event to fire
127
- if (event.EventDataType == MessageType.PageView || event.EventDataType == MessageType.PageEvent) {
128
- eventPayload = generateEventFunction(event, conversionLabel, customProps);
129
- } else if (event.EventDataType == MessageType.Commerce && event.ProductAction) {
130
- eventPayload = generateCommerceEvent(event, conversionLabel, customProps);
131
- }
132
-
133
- if (eventPayload) {
134
- reportEvent = sendEventFunction(eventPayload);
135
- }
136
-
137
- if (reportEvent && reportingService) {
138
- reportingService(self, event);
139
-
140
- return 'Successfully sent to ' + name;
141
- }
103
+ sendEventFunction = sendGtagEvent;
104
+ generateEventFunction = generateGtagEvent;
105
+ generateCommerceEvent = generateGtagCommerceEvent;
106
+ } else if (window.google_trackConversion) {
107
+ // window.google_trackConversion is a legacy API and will be deprecated
108
+ sendEventFunction = sendAdwordsEvent;
109
+ generateEventFunction = generateAdwordsEvent;
110
+ generateCommerceEvent = generateAdwordsCommerceEvent;
111
+ } else {
112
+ eventQueue.push({
113
+ action: processEvent,
114
+ data: event,
115
+ });
116
+
117
+ return (
118
+ "Can't send to forwarder " +
119
+ name +
120
+ ', not initialized. Event added to queue.'
121
+ );
122
+ }
123
+
124
+ // Get conversionLabel to be used for event generation
125
+ var conversionLabel = getConversionLabel(event);
126
+ var customProps = getCustomProps(event);
127
+
128
+ if (conversionLabel) {
129
+ // Determines the proper event to fire
130
+ if (
131
+ event.EventDataType == MessageType.PageView ||
132
+ event.EventDataType == MessageType.PageEvent
133
+ ) {
134
+ eventPayload = generateEventFunction(
135
+ event,
136
+ conversionLabel,
137
+ customProps
138
+ );
139
+ } else if (
140
+ event.EventDataType == MessageType.Commerce &&
141
+ event.ProductAction
142
+ ) {
143
+ eventPayload = generateCommerceEvent(
144
+ event,
145
+ conversionLabel,
146
+ customProps
147
+ );
142
148
  }
143
149
 
144
- return 'Can\'t send to forwarder: ' + name + '. Event not mapped';
145
- } catch (e) {
146
- console.error('Can\t send to forwarder', e);
147
- return 'Can\'t send to forwarder: ' + name + ' ' + e;
150
+ if (eventPayload) {
151
+ reportEvent = sendEventFunction(eventPayload);
152
+ }
153
+
154
+ if (reportEvent && reportingService) {
155
+ reportingService(self, event);
156
+
157
+ return 'Successfully sent to ' + name;
158
+ }
148
159
  }
149
- } else {
150
- eventQueue.push({
151
- action: processEvent,
152
- data: event
153
- });
154
- }
155
160
 
156
- return 'Can\'t send to forwarder ' + name + ', not initialized. Event added to queue.';
161
+ return (
162
+ "Can't send to forwarder: " + name + '. Event not mapped'
163
+ );
164
+ } catch (e) {
165
+ console.error('Can\t send to forwarder', e);
166
+ return "Can't send to forwarder: " + name + ' ' + e;
167
+ }
168
+ } else {
169
+ eventQueue.push({
170
+ action: processEvent,
171
+ data: event,
172
+ });
157
173
  }
158
174
 
159
- function hasEnhancedConversionData(customFlags) {
160
- return customFlags && Object.keys(customFlags).length && customFlags[ENHANCED_CONVERSION_DATA];
161
- }
175
+ return (
176
+ "Can't send to forwarder " +
177
+ name +
178
+ ', not initialized. Event added to queue.'
179
+ );
180
+ }
162
181
 
163
- function parseEnhancedConversionData(conversionData) {
164
- // Checks if conversion data in custom flags is a stringified object
165
- // Conversion data should only be a stringified object or a JS object
166
- if (typeof conversionData === 'string') {
167
- try {
168
- return JSON.parse(conversionData);
169
- } catch (error) {
170
- console.warn('Unrecognized Enhanced Conversion Data Format', conversionData, error);
171
- return {};
172
- }
173
- } else if (typeof conversionData === 'object') {
174
- // Not a stringified object so it can be used as-is. However,
175
- // we want to avoid mutating the original state, so we make a copy.
176
- return cloneObject(conversionData);
177
- } else {
178
- console.warn('Unrecognized Enhanced Conversion Data Format', conversionData);
182
+ function hasEnhancedConversionData(customFlags) {
183
+ return (
184
+ customFlags &&
185
+ Object.keys(customFlags).length &&
186
+ customFlags[ENHANCED_CONVERSION_DATA]
187
+ );
188
+ }
189
+
190
+ function parseEnhancedConversionData(conversionData) {
191
+ // Checks if conversion data in custom flags is a stringified object
192
+ // Conversion data should only be a stringified object or a JS object
193
+ if (typeof conversionData === 'string') {
194
+ try {
195
+ return JSON.parse(conversionData);
196
+ } catch (error) {
197
+ console.warn(
198
+ 'Unrecognized Enhanced Conversion Data Format',
199
+ conversionData,
200
+ error
201
+ );
179
202
  return {};
180
203
  }
181
-
204
+ } else if (typeof conversionData === 'object') {
205
+ // Not a stringified object so it can be used as-is. However,
206
+ // we want to avoid mutating the original state, so we make a copy.
207
+ return cloneObject(conversionData);
208
+ } else {
209
+ console.warn(
210
+ 'Unrecognized Enhanced Conversion Data Format',
211
+ conversionData
212
+ );
213
+ return {};
182
214
  }
215
+ }
183
216
 
184
- // Converts an mParticle Commerce Event into either Legacy or gtag Event
185
- function generateCommerceEvent(mPEvent, conversionLabel, isPageEvent) {
186
- if (mPEvent.ProductAction
187
- && mPEvent.ProductAction.ProductList
188
- && mPEvent.ProductAction.ProductActionType) {
189
-
190
- if (window.gtag && forwarderSettings.enableGtag == 'True') {
191
- return generateGtagCommerceEvent(mPEvent, conversionLabel, isPageEvent);
192
- } else if (window.google_trackConversion) {
193
- return generateAdwordsCommerceEvent(mPEvent, conversionLabel, isPageEvent);
194
- } else {
195
- console.error('Unrecognized Commerce Event', mPEvent);
196
- return false;
197
- }
198
-
217
+ // Converts an mParticle Commerce Event into either Legacy or gtag Event
218
+ function generateCommerceEvent(mPEvent, conversionLabel, isPageEvent) {
219
+ if (
220
+ mPEvent.ProductAction &&
221
+ mPEvent.ProductAction.ProductList &&
222
+ mPEvent.ProductAction.ProductActionType
223
+ ) {
224
+ if (window.gtag && forwarderSettings.enableGtag == 'True') {
225
+ return generateGtagCommerceEvent(
226
+ mPEvent,
227
+ conversionLabel,
228
+ isPageEvent
229
+ );
230
+ } else if (window.google_trackConversion) {
231
+ return generateAdwordsCommerceEvent(
232
+ mPEvent,
233
+ conversionLabel,
234
+ isPageEvent
235
+ );
199
236
  } else {
237
+ console.error('Unrecognized Commerce Event', mPEvent);
200
238
  return false;
201
239
  }
240
+ } else {
241
+ return false;
202
242
  }
243
+ }
203
244
 
204
- function getUserConsentState() {
205
- var userConsentState = {};
245
+ function getUserConsentState() {
246
+ var userConsentState = {};
206
247
 
207
- if (window.mParticle && window.mParticle.Identity && window.mParticle.Identity.getCurrentUser) {
208
- var currentUser = window.mParticle.Identity.getCurrentUser();
248
+ if (
249
+ window.mParticle &&
250
+ window.mParticle.Identity &&
251
+ window.mParticle.Identity.getCurrentUser
252
+ ) {
253
+ var currentUser = window.mParticle.Identity.getCurrentUser();
209
254
 
210
- if (!currentUser) {
211
- return {};
212
- }
255
+ if (!currentUser) {
256
+ return {};
257
+ }
213
258
 
214
- var consentState =
215
- window.mParticle.Identity.getCurrentUser().getConsentState();
259
+ var consentState = window.mParticle.Identity.getCurrentUser().getConsentState();
216
260
 
217
- if (consentState && consentState.getGDPRConsentState) {
218
- userConsentState = consentState.getGDPRConsentState();
219
- }
261
+ if (consentState && consentState.getGDPRConsentState) {
262
+ userConsentState = consentState.getGDPRConsentState();
220
263
  }
221
-
222
- return userConsentState;
223
264
  }
224
265
 
225
- function getEventConsentState(eventConsentState) {
226
- return eventConsentState && eventConsentState.getGDPRConsentState
227
- ? eventConsentState.getGDPRConsentState()
228
- : {};
229
- }
230
- // ** Adwords Events
231
- function getBaseAdWordEvent() {
232
- var adWordEvent = {};
233
- adWordEvent.google_conversion_value = 0;
234
- adWordEvent.google_conversion_language = 'en';
235
- adWordEvent.google_conversion_format = '3';
236
- adWordEvent.google_conversion_color = 'ffffff';
237
- adWordEvent.google_remarketing_only = forwarderSettings.remarketingOnly == 'True';
238
- adWordEvent.google_conversion_id = forwarderSettings.conversionId;
239
- return adWordEvent;
240
- }
266
+ return userConsentState;
267
+ }
241
268
 
242
- function generateAdwordsEvent(mPEvent, conversionLabel, customProps) {
243
- var adWordEvent = getBaseAdWordEvent();
244
- adWordEvent.google_conversion_label = conversionLabel;
245
- adWordEvent.google_custom_params = customProps;
269
+ function getEventConsentState(eventConsentState) {
270
+ return eventConsentState && eventConsentState.getGDPRConsentState
271
+ ? eventConsentState.getGDPRConsentState()
272
+ : {};
273
+ }
246
274
 
247
- return adWordEvent;
248
- }
275
+ // ** Adwords Events
276
+ function getBaseAdWordEvent() {
277
+ var adWordEvent = {};
278
+ adWordEvent.google_conversion_value = 0;
279
+ adWordEvent.google_conversion_language = 'en';
280
+ adWordEvent.google_conversion_format = '3';
281
+ adWordEvent.google_conversion_color = 'ffffff';
282
+ adWordEvent.google_remarketing_only =
283
+ forwarderSettings.remarketingOnly == 'True';
284
+ adWordEvent.google_conversion_id = forwarderSettings.conversionId;
285
+ return adWordEvent;
286
+ }
249
287
 
250
- function generateAdwordsCommerceEvent(mPEvent, conversionLabel, customProps) {
251
- var adWordEvent = getBaseAdWordEvent();
252
- adWordEvent.google_conversion_label = conversionLabel;
288
+ function generateAdwordsEvent(mPEvent, conversionLabel, customProps) {
289
+ var adWordEvent = getBaseAdWordEvent();
290
+ adWordEvent.google_conversion_label = conversionLabel;
291
+ adWordEvent.google_custom_params = customProps;
253
292
 
254
- if (mPEvent.ProductAction.ProductActionType === mParticle.ProductActionType.Purchase
255
- && mPEvent.ProductAction.TransactionId) {
256
- adWordEvent.google_conversion_order_id = mPEvent.ProductAction.TransactionId;
257
- }
293
+ return adWordEvent;
294
+ }
258
295
 
259
- if (mPEvent.CurrencyCode) {
260
- adWordEvent.google_conversion_currency = mPEvent.CurrencyCode;
261
- }
296
+ function generateAdwordsCommerceEvent(
297
+ mPEvent,
298
+ conversionLabel,
299
+ customProps
300
+ ) {
301
+ var adWordEvent = getBaseAdWordEvent();
302
+ adWordEvent.google_conversion_label = conversionLabel;
262
303
 
263
- if (mPEvent.ProductAction.TotalAmount) {
264
- adWordEvent.google_conversion_value = mPEvent.ProductAction.TotalAmount;
265
- }
304
+ if (
305
+ mPEvent.ProductAction.ProductActionType ===
306
+ mParticle.ProductActionType.Purchase &&
307
+ mPEvent.ProductAction.TransactionId
308
+ ) {
309
+ adWordEvent.google_conversion_order_id =
310
+ mPEvent.ProductAction.TransactionId;
311
+ }
266
312
 
267
- adWordEvent.google_custom_params = customProps;
268
- return adWordEvent;
313
+ if (mPEvent.CurrencyCode) {
314
+ adWordEvent.google_conversion_currency = mPEvent.CurrencyCode;
269
315
  }
270
316
 
271
- function getConsentSettings() {
272
- var consentSettings = {};
317
+ if (mPEvent.ProductAction.TotalAmount) {
318
+ adWordEvent.google_conversion_value =
319
+ mPEvent.ProductAction.TotalAmount;
320
+ }
273
321
 
274
- var googleToMpConsentSettingsMapping = {
275
- // Inherited from S2S Integration Settings
276
- ad_user_data: 'defaultAdUserDataConsent',
277
- ad_personalization: 'defaultAdPersonalizationConsent',
322
+ adWordEvent.google_custom_params = customProps;
323
+ return adWordEvent;
324
+ }
278
325
 
279
- // Unique to Web Kits
280
- ad_storage: 'defaultAdStorageConsentWeb',
281
- analytics_storage: 'defaultAnalyticsStorageConsentWeb'
282
- };
326
+ function getConsentSettings() {
327
+ var consentSettings = {};
328
+
329
+ var googleToMpConsentSettingsMapping = {
330
+ // Inherited from S2S Integration Settings
331
+ ad_user_data: 'defaultAdUserDataConsent',
332
+ ad_personalization: 'defaultAdPersonalizationConsent',
333
+
334
+ // Unique to Web Kits
335
+ ad_storage: 'defaultAdStorageConsentWeb',
336
+ analytics_storage: 'defaultAnalyticsStorageConsentWeb',
337
+ };
338
+
339
+ Object.keys(googleToMpConsentSettingsMapping).forEach(function(
340
+ googleConsentKey
341
+ ) {
342
+ var mpConsentSettingKey =
343
+ googleToMpConsentSettingsMapping[googleConsentKey];
344
+ var googleConsentValuesKey = forwarderSettings[mpConsentSettingKey];
345
+
346
+ if (googleConsentValuesKey && mpConsentSettingKey) {
347
+ consentSettings[googleConsentKey] =
348
+ googleConsentValues[googleConsentValuesKey];
349
+ }
350
+ });
283
351
 
284
- Object.keys(googleToMpConsentSettingsMapping).forEach(function (googleConsentKey) {
285
- var mpConsentSettingKey = googleToMpConsentSettingsMapping[googleConsentKey];
286
- var googleConsentValuesKey = forwarderSettings[mpConsentSettingKey];
352
+ return consentSettings;
353
+ }
287
354
 
288
- if (googleConsentValuesKey && mpConsentSettingKey){
289
- consentSettings[googleConsentKey] = googleConsentValues[googleConsentValuesKey];
290
- }
291
- });
292
-
293
- return consentSettings;
294
- }
355
+ // gtag Events
356
+ function getBaseGtagEvent(conversionLabel) {
357
+ return {
358
+ send_to: gtagSiteId + '/' + conversionLabel,
359
+ value: 0,
360
+ language: 'en',
361
+ remarketing_only: forwarderSettings.remarketingOnly == 'True',
362
+ };
363
+ }
295
364
 
296
- // gtag Events
297
- function getBaseGtagEvent(conversionLabel) {
298
- return {
299
- 'send_to': gtagSiteId + '/' + conversionLabel,
300
- 'value': 0,
301
- 'language': 'en',
302
- 'remarketing_only': forwarderSettings.remarketingOnly == 'True'
303
- }
365
+ function generateGtagEvent(mPEvent, conversionLabel, customProps) {
366
+ if (!conversionLabel) {
367
+ return null;
304
368
  }
305
369
 
306
- function generateGtagEvent(mPEvent, conversionLabel, customProps) {
307
- if (!conversionLabel) { return null; }
308
- var conversionPayload = getBaseGtagEvent(conversionLabel);
309
- conversionPayload.transaction_id = mPEvent.SourceMessageId;
310
- return mergeObjects(conversionPayload, customProps);
311
- }
370
+ var conversionPayload = getBaseGtagEvent(conversionLabel);
371
+ conversionPayload.transaction_id = mPEvent.SourceMessageId;
372
+ return mergeObjects(conversionPayload, customProps);
373
+ }
312
374
 
313
- function generateGtagCommerceEvent(mPEvent, conversionLabel, customProps) {
314
- if (!conversionLabel) { return null; }
315
- var conversionPayload = getBaseGtagEvent(conversionLabel);
375
+ function generateGtagCommerceEvent(mPEvent, conversionLabel, customProps) {
376
+ if (!conversionLabel) {
377
+ return null;
378
+ }
316
379
 
317
- if (mPEvent.ProductAction.ProductActionType === mParticle.ProductActionType.Purchase
318
- && mPEvent.ProductAction.TransactionId) {
319
- conversionPayload.transaction_id = mPEvent.ProductAction.TransactionId;
320
- } else {
321
- conversionPayload.transaction_id = mPEvent.SourceMessageId;
322
- }
380
+ var conversionPayload = getBaseGtagEvent(conversionLabel);
323
381
 
324
- if (mPEvent.CurrencyCode) {
325
- conversionPayload.currency = mPEvent.CurrencyCode;
326
- }
382
+ if (
383
+ mPEvent.ProductAction.ProductActionType ===
384
+ mParticle.ProductActionType.Purchase &&
385
+ mPEvent.ProductAction.TransactionId
386
+ ) {
387
+ conversionPayload.transaction_id =
388
+ mPEvent.ProductAction.TransactionId;
389
+ } else {
390
+ conversionPayload.transaction_id = mPEvent.SourceMessageId;
391
+ }
327
392
 
328
- if (mPEvent.ProductAction.TotalAmount) {
329
- conversionPayload.value = mPEvent.ProductAction.TotalAmount;
330
- }
393
+ if (mPEvent.CurrencyCode) {
394
+ conversionPayload.currency = mPEvent.CurrencyCode;
395
+ }
331
396
 
332
- return mergeObjects(conversionPayload, customProps);
397
+ if (mPEvent.ProductAction.TotalAmount) {
398
+ conversionPayload.value = mPEvent.ProductAction.TotalAmount;
333
399
  }
334
400
 
335
- function sendGtagEvent(payload) {
336
- // https://go.mparticle.com/work/SQDSDKS-6165
337
- try {
338
- gtag('event', 'conversion', payload);
339
- } catch (e) {
340
- console.error('gtag is not available to send payload: ', payload, e);
341
- return false;
342
- }
343
- return true;
401
+ return mergeObjects(conversionPayload, customProps);
402
+ }
403
+
404
+ function sendGtagEvent(payload) {
405
+ // https://go.mparticle.com/work/SQDSDKS-6165
406
+ try {
407
+ gtag('event', 'conversion', payload);
408
+ } catch (e) {
409
+ console.error(
410
+ 'gtag is not available to send payload: ',
411
+ payload,
412
+ e
413
+ );
414
+ return false;
344
415
  }
416
+ return true;
417
+ }
345
418
 
346
- function maybeSendConsentUpdateToGoogle(consentState) {
347
- if (
348
- consentPayloadAsString &&
349
- forwarderSettings.consentMappingWeb &&
350
- !isEmpty(consentState)
351
- ) {
352
- var updatedConsentPayload = generateConsentStatePayloadFromMappings(
353
- consentState,
354
- consentMappings,
355
- );
419
+ function maybeSendConsentUpdateToGoogle(consentState) {
420
+ if (
421
+ consentPayloadAsString &&
422
+ forwarderSettings.consentMappingWeb &&
423
+ !isEmpty(consentState)
424
+ ) {
425
+ var updatedConsentPayload = generateConsentStatePayloadFromMappings(
426
+ consentState,
427
+ consentMappings
428
+ );
356
429
 
357
- var eventConsentAsString =
358
- JSON.stringify(updatedConsentPayload);
430
+ var eventConsentAsString = JSON.stringify(updatedConsentPayload);
359
431
 
360
- if (eventConsentAsString !== consentPayloadAsString) {
361
- sendGtagConsentUpdate(updatedConsentPayload);
362
- consentPayloadAsString = eventConsentAsString;
363
- }
432
+ if (eventConsentAsString !== consentPayloadAsString) {
433
+ sendGtagConsentUpdate(updatedConsentPayload);
434
+ consentPayloadAsString = eventConsentAsString;
364
435
  }
365
436
  }
437
+ }
366
438
 
367
- function sendGtagConsentDefaults(payload) {
368
- // https://go.mparticle.com/work/SQDSDKS-6165
369
- consentPayloadAsString = JSON.stringify(
370
- payload
439
+ function sendGtagConsentDefaults(payload) {
440
+ // https://go.mparticle.com/work/SQDSDKS-6165
441
+ consentPayloadAsString = JSON.stringify(payload);
442
+
443
+ try {
444
+ gtag('consent', 'default', payload);
445
+ } catch (e) {
446
+ console.error(
447
+ 'gtag is not available to send consent defaults: ',
448
+ payload,
449
+ e
371
450
  );
372
-
373
- try {
374
- gtag('consent', 'default', payload);
375
- } catch (e) {
376
- console.error('gtag is not available to send consent defaults: ', payload, e);
377
- return false;
378
- }
379
- return true;
451
+ return false;
380
452
  }
453
+ return true;
454
+ }
381
455
 
382
- function sendGtagConsentUpdate(payload) {
383
- // https://go.mparticle.com/work/SQDSDKS-6165
384
- try {
385
- gtag('consent', 'update', payload);
386
- } catch (e) {
387
- console.error('gtag is not available to send consent update: ', payload, e);
388
- return false;
389
- }
390
- return true;
456
+ function sendGtagConsentUpdate(payload) {
457
+ // https://go.mparticle.com/work/SQDSDKS-6165
458
+ try {
459
+ gtag('consent', 'update', payload);
460
+ } catch (e) {
461
+ console.error(
462
+ 'gtag is not available to send consent update: ',
463
+ payload,
464
+ e
465
+ );
466
+ return false;
391
467
  }
468
+ return true;
469
+ }
392
470
 
393
- function sendAdwordsEvent(payload) {
394
- try {
395
- window.google_trackConversion(payload);
396
- } catch (e) {
397
- console.error('google_trackConversion is not available to send payload: ', payload, e);
398
- return false;
399
- }
400
- return true;
471
+ function sendAdwordsEvent(payload) {
472
+ try {
473
+ window.google_trackConversion(payload);
474
+ } catch (e) {
475
+ console.error(
476
+ 'google_trackConversion is not available to send payload: ',
477
+ payload,
478
+ e
479
+ );
480
+ return false;
401
481
  }
482
+ return true;
483
+ }
402
484
 
403
- // Creates a new Consent State Payload based on Consent State and Mapping
404
- function generateConsentStatePayloadFromMappings(consentState, mappings) {
405
- if (!mappings) return {};
406
- var payload = cloneObject(consentPayloadDefaults);
407
-
408
- for (var i = 0; i <= mappings.length - 1; i++) {
409
- var mappingEntry = mappings[i];
410
- // Although consent purposes can be inputted into the UI in any casing
411
- // the SDK will automatically lowercase them to prevent pseudo-duplicate
412
- // consent purposes, so we call `toLowerCase` on the consentMapping purposes here
413
- var mpMappedConsentName = mappingEntry.map.toLowerCase();
414
- // var mpMappedConsentName = mappingEntry.map;
415
- var googleMappedConsentName = mappingEntry.value;
485
+ // Creates a new Consent State Payload based on Consent State and Mapping
486
+ function generateConsentStatePayloadFromMappings(consentState, mappings) {
487
+ if (!mappings) return {};
488
+ var payload = cloneObject(consentPayloadDefaults);
416
489
 
417
- if (
418
- consentState[mpMappedConsentName] &&
419
- googleConsentProperties.indexOf(googleMappedConsentName) !== -1
420
- ) {
421
- payload[googleMappedConsentName] = consentState[mpMappedConsentName]
422
- .Consented
423
- ? googleConsentValues.Granted
424
- : googleConsentValues.Denied;
425
- }
490
+ for (var i = 0; i <= mappings.length - 1; i++) {
491
+ var mappingEntry = mappings[i];
492
+ // Although consent purposes can be inputted into the UI in any casing
493
+ // the SDK will automatically lowercase them to prevent pseudo-duplicate
494
+ // consent purposes, so we call `toLowerCase` on the consentMapping purposes here
495
+ var mpMappedConsentName = mappingEntry.map.toLowerCase();
496
+ // var mpMappedConsentName = mappingEntry.map;
497
+ var googleMappedConsentName = mappingEntry.value;
498
+
499
+ if (
500
+ consentState[mpMappedConsentName] &&
501
+ googleConsentProperties.indexOf(googleMappedConsentName) !== -1
502
+ ) {
503
+ payload[googleMappedConsentName] = consentState[
504
+ mpMappedConsentName
505
+ ].Consented
506
+ ? googleConsentValues.Granted
507
+ : googleConsentValues.Denied;
426
508
  }
427
-
428
- return payload;
429
509
  }
430
510
 
431
- // Looks up an Event's conversionLabel from customAttributeMappings based on computed jsHash value
432
- function getConversionLabel(event) {
433
- var jsHash = calculateJSHash(event.EventDataType, event.EventCategory, event.EventName);
434
- var type = event.EventDataType === MessageType.PageEvent ? 'EventClass.Id' : 'EventClassDetails.Id';
435
- var conversionLabel = null;
436
- var mappingEntry = findValueInMapping(jsHash, type, labels);
437
-
438
- if (mappingEntry) {
439
- conversionLabel = mappingEntry.value;
440
- }
511
+ return payload;
512
+ }
441
513
 
442
- return conversionLabel;
443
- }
514
+ // Looks up an Event's conversionLabel from customAttributeMappings based on computed jsHash value
515
+ function getConversionLabel(event) {
516
+ var jsHash = calculateJSHash(
517
+ event.EventDataType,
518
+ event.EventCategory,
519
+ event.EventName
520
+ );
521
+ var type =
522
+ event.EventDataType === MessageType.PageEvent
523
+ ? 'EventClass.Id'
524
+ : 'EventClassDetails.Id';
525
+ var conversionLabel = null;
526
+ var mappingEntry = findValueInMapping(jsHash, type, labels);
527
+
528
+ if (mappingEntry) {
529
+ conversionLabel = mappingEntry.value;
530
+ }
531
+
532
+ return conversionLabel;
533
+ }
444
534
 
445
- // Filters Event.EventAttributes for attributes that are in customAttributeMappings
446
- function getCustomProps(event) {
447
- var customProps = {};
448
- var attributes = event.EventAttributes;
449
- var type = event.EventDataType === MessageType.PageEvent ? 'EventAttributeClass.Id' : 'EventAttributeClassDetails.Id';
450
-
451
- if (attributes) {
452
- for (var attributeKey in attributes) {
453
- if (attributes.hasOwnProperty(attributeKey)) {
454
- var jsHash = calculateJSHash(event.EventDataType, event.EventCategory, attributeKey);
455
- var mappingEntry = findValueInMapping(jsHash, type, customAttributeMappings);
456
- if (mappingEntry) {
457
- customProps[mappingEntry.value] = attributes[attributeKey];
458
- }
535
+ // Filters Event.EventAttributes for attributes that are in customAttributeMappings
536
+ function getCustomProps(event) {
537
+ var customProps = {};
538
+ var attributes = event.EventAttributes;
539
+ var type =
540
+ event.EventDataType === MessageType.PageEvent
541
+ ? 'EventAttributeClass.Id'
542
+ : 'EventAttributeClassDetails.Id';
543
+
544
+ if (attributes) {
545
+ for (var attributeKey in attributes) {
546
+ if (attributes.hasOwnProperty(attributeKey)) {
547
+ var jsHash = calculateJSHash(
548
+ event.EventDataType,
549
+ event.EventCategory,
550
+ attributeKey
551
+ );
552
+ var mappingEntry = findValueInMapping(
553
+ jsHash,
554
+ type,
555
+ customAttributeMappings
556
+ );
557
+ if (mappingEntry) {
558
+ customProps[mappingEntry.value] =
559
+ attributes[attributeKey];
459
560
  }
460
561
  }
461
562
  }
462
-
463
- return customProps;
464
563
  }
465
564
 
466
- function findValueInMapping(jsHash, type, mapping) {
467
- if (mapping) {
468
- var filteredArray = mapping.filter(function (mappingEntry) {
565
+ return customProps;
566
+ }
469
567
 
470
- if (mappingEntry.jsmap && mappingEntry.maptype && mappingEntry.value) {
471
- return mappingEntry.jsmap == jsHash && mappingEntry.maptype == type;
472
- }
568
+ function findValueInMapping(jsHash, type, mapping) {
569
+ if (mapping) {
570
+ var filteredArray = mapping.filter(function(mappingEntry) {
571
+ if (
572
+ mappingEntry.jsmap &&
573
+ mappingEntry.maptype &&
574
+ mappingEntry.value
575
+ ) {
576
+ return (
577
+ mappingEntry.jsmap == jsHash &&
578
+ mappingEntry.maptype == type
579
+ );
580
+ }
473
581
 
474
- return false;
475
- });
582
+ return false;
583
+ });
476
584
 
477
- if (filteredArray && filteredArray.length > 0) {
478
- return filteredArray[0];
479
- }
585
+ if (filteredArray && filteredArray.length > 0) {
586
+ return filteredArray[0];
480
587
  }
481
- return null;
482
588
  }
589
+ return null;
590
+ }
483
591
 
484
- function calculateJSHash(eventDataType, eventCategory, name) {
485
- var preHash = [eventDataType, eventCategory, name].join('');
592
+ function calculateJSHash(eventDataType, eventCategory, name) {
593
+ var preHash = [eventDataType, eventCategory, name].join('');
486
594
 
487
- return mParticle.generateHash(preHash);
488
- }
595
+ return mParticle.generateHash(preHash);
596
+ }
489
597
 
490
- function loadGtagSnippet() {
491
- (function () {
492
- window.dataLayer = window.dataLayer || [];
493
- window.gtag = function(){dataLayer.push(arguments);};
494
-
495
- var gTagScript = document.createElement('script');
496
- gTagScript.async = true;
497
- gTagScript.onload = function () {
498
- gtag('js', new Date());
499
- if (forwarderSettings.enableEnhancedConversions === 'True') {
500
- gtag('config', gtagSiteId, {
501
- allow_enhanced_conversions: true
502
- });
503
- } else {
504
- gtag('config', gtagSiteId);
505
- }
506
- isInitialized = true;
507
- processQueue(eventQueue);
508
- };
509
- gTagScript.src = 'https://www.googletagmanager.com/gtag/js?id=' + gtagSiteId;
510
- document.getElementsByTagName('head')[0].appendChild(gTagScript);
511
- })();
512
- }
598
+ function loadGtagSnippet() {
599
+ (function() {
600
+ window.dataLayer = window.dataLayer || [];
601
+ window.gtag = function() {
602
+ dataLayer.push(arguments);
603
+ };
513
604
 
514
- function loadLegacySnippet() {
515
- (function () {
516
- var googleAdwords = document.createElement('script');
517
- googleAdwords.type = 'text/javascript';
518
- googleAdwords.async = true;
519
- googleAdwords.onload = function() {
520
- isInitialized = true;
521
- processQueue(eventQueue);
522
- };
523
- googleAdwords.src = ('https:' == document.location.protocol ? 'https' : 'http') + '://www.googleadservices.com/pagead/conversion_async.js';
524
- document.getElementsByTagName('head')[0].appendChild(googleAdwords);
525
- })();
526
- }
605
+ var gTagScript = document.createElement('script');
606
+ gTagScript.async = true;
607
+ gTagScript.onload = function() {
608
+ gtag('js', new Date());
609
+ if (forwarderSettings.enableEnhancedConversions === 'True') {
610
+ gtag('config', gtagSiteId, {
611
+ allow_enhanced_conversions: true,
612
+ });
613
+ } else {
614
+ gtag('config', gtagSiteId);
615
+ }
616
+ isInitialized = true;
617
+ processQueue(eventQueue);
618
+ };
619
+ gTagScript.src =
620
+ 'https://www.googletagmanager.com/gtag/js?id=' + gtagSiteId;
621
+ document.getElementsByTagName('head')[0].appendChild(gTagScript);
622
+ })();
623
+ }
527
624
 
528
- // https://go.mparticle.com/work/SQDSDKS-6166
529
- function initForwarder(settings, service, testMode) {
530
- window.enhanced_conversion_data = {};
531
- forwarderSettings = settings;
532
- reportingService = service;
625
+ function loadLegacySnippet() {
626
+ (function() {
627
+ var googleAdwords = document.createElement('script');
628
+ googleAdwords.type = 'text/javascript';
629
+ googleAdwords.async = true;
630
+ googleAdwords.onload = function() {
631
+ isInitialized = true;
632
+ processQueue(eventQueue);
633
+ };
634
+ googleAdwords.src =
635
+ ('https:' == document.location.protocol ? 'https' : 'http') +
636
+ '://www.googleadservices.com/pagead/conversion_async.js';
637
+ document.getElementsByTagName('head')[0].appendChild(googleAdwords);
638
+ })();
639
+ }
533
640
 
534
- try {
535
- if (!forwarderSettings.conversionId) {
536
- return 'Can\'t initialize forwarder: ' + name + ', conversionId is not defined';
537
- }
641
+ // https://go.mparticle.com/work/SQDSDKS-6166
642
+ function initForwarder(settings, service, testMode) {
643
+ window.enhanced_conversion_data = {};
644
+ forwarderSettings = settings;
645
+ reportingService = service;
646
+
647
+ try {
648
+ if (!forwarderSettings.conversionId) {
649
+ return (
650
+ "Can't initialize forwarder: " +
651
+ name +
652
+ ', conversionId is not defined'
653
+ );
654
+ }
538
655
 
539
- gtagSiteId = "AW-" + forwarderSettings.conversionId;
656
+ gtagSiteId = 'AW-' + forwarderSettings.conversionId;
540
657
 
541
- if (testMode !== true) {
542
- if (forwarderSettings.enableGtag == 'True') {
543
- loadGtagSnippet();
544
- } else {
545
- loadLegacySnippet();
546
- }
658
+ if (testMode !== true) {
659
+ if (forwarderSettings.enableGtag == 'True') {
660
+ loadGtagSnippet();
547
661
  } else {
548
- isInitialized = true;
549
- processQueue(eventQueue);
662
+ loadLegacySnippet();
550
663
  }
664
+ } else {
665
+ isInitialized = true;
666
+ processQueue(eventQueue);
667
+ }
551
668
 
552
- if (!forwarderSettings.conversionId) {
553
- return 'Can\'t initialize forwarder: ' + name + ', conversionId is not defined';
554
- }
669
+ if (!forwarderSettings.conversionId) {
670
+ return (
671
+ "Can't initialize forwarder: " +
672
+ name +
673
+ ', conversionId is not defined'
674
+ );
675
+ }
555
676
 
556
- // https://go.mparticle.com/work/SQDSDKS-6165
557
- if (window.gtag && forwarderSettings.enableGtag === 'True') {
558
- if (forwarderSettings.consentMappingWeb) {
559
- consentMappings = parseSettingsString(
560
- forwarderSettings.consentMappingWeb
561
- );
562
- } else {
563
- // Ensures consent mappings is an empty array
564
- // for future use
565
- consentMappings = [];
566
- }
567
-
568
- consentPayloadDefaults = getConsentSettings();
569
- var defaultConsentPayload = cloneObject(consentPayloadDefaults);
570
- var updatedConsentState = getUserConsentState();
571
- var updatedDefaultConsentPayload =
572
- generateConsentStatePayloadFromMappings(
573
- updatedConsentState,
574
- consentMappings
575
- );
576
-
577
- if (!isEmpty(defaultConsentPayload)) {
578
- sendGtagConsentDefaults(defaultConsentPayload);
579
- } else if (!isEmpty(updatedDefaultConsentPayload)) {
580
- sendGtagConsentDefaults(updatedDefaultConsentPayload);
581
- }
677
+ // https://go.mparticle.com/work/SQDSDKS-6165
678
+ if (window.gtag && forwarderSettings.enableGtag === 'True') {
679
+ if (forwarderSettings.consentMappingWeb) {
680
+ consentMappings = parseSettingsString(
681
+ forwarderSettings.consentMappingWeb
682
+ );
683
+ } else {
684
+ // Ensures consent mappings is an empty array
685
+ // for future use
686
+ consentMappings = [];
687
+ }
582
688
 
583
- maybeSendConsentUpdateToGoogle(updatedConsentState);
689
+ consentPayloadDefaults = getConsentSettings();
690
+ var defaultConsentPayload = cloneObject(consentPayloadDefaults);
691
+ var updatedConsentState = getUserConsentState();
692
+ var updatedDefaultConsentPayload = generateConsentStatePayloadFromMappings(
693
+ updatedConsentState,
694
+ consentMappings
695
+ );
584
696
 
697
+ if (!isEmpty(defaultConsentPayload)) {
698
+ sendGtagConsentDefaults(defaultConsentPayload);
699
+ } else if (!isEmpty(updatedDefaultConsentPayload)) {
700
+ sendGtagConsentDefaults(updatedDefaultConsentPayload);
585
701
  }
586
702
 
587
- forwarderSettings.remarketingOnly = forwarderSettings.remarketingOnly == 'True';
703
+ maybeSendConsentUpdateToGoogle(updatedConsentState);
704
+ }
588
705
 
589
- try {
590
- if (forwarderSettings.labels) {
591
- labels = JSON.parse(forwarderSettings.labels.replace(/&quot;/g, '"'));
592
- }
706
+ forwarderSettings.remarketingOnly =
707
+ forwarderSettings.remarketingOnly == 'True';
593
708
 
594
- if (forwarderSettings.customParameters) {
595
- customAttributeMappings = JSON.parse(forwarderSettings.customParameters.replace(/&quot;/g, '"'));
596
- }
597
- } catch (e) {
598
- return 'Can\'t initialize forwarder: ' + name + ', Could not process event to label mapping';
709
+ try {
710
+ if (forwarderSettings.labels) {
711
+ labels = JSON.parse(
712
+ forwarderSettings.labels.replace(/&quot;/g, '"')
713
+ );
599
714
  }
600
715
 
601
- return 'Successfully initialized: ' + name;
602
- }
603
- catch (e) {
604
- return 'Failed to initialize: ' + name;
605
- }
606
- }
607
-
608
- function processQueue(queue) {
609
- var item;
610
-
611
- if ((window.gtag || window.google_trackConversion) && queue.length > 0) {
612
- try {
613
- while (queue.length > 0) {
614
- item = queue.shift();
615
- item.action(item.data);
616
- }
617
- } catch (e) {
618
- console.error('Error on mParticle Adwords Kit', e);
716
+ if (forwarderSettings.customParameters) {
717
+ customAttributeMappings = JSON.parse(
718
+ forwarderSettings.customParameters.replace(
719
+ /&quot;/g,
720
+ '"'
721
+ )
722
+ );
619
723
  }
724
+ } catch (e) {
725
+ return (
726
+ "Can't initialize forwarder: " +
727
+ name +
728
+ ', Could not process event to label mapping'
729
+ );
620
730
  }
621
- }
622
731
 
623
- this.init = initForwarder;
624
- this.process = processEvent;
625
- this.processQueue = processQueue;
626
- };
627
-
628
- function getId() {
629
- return moduleId;
630
- }
631
-
632
- function register(config) {
633
- if (!config) {
634
- console.log('You must pass a config object to register the kit ' + name);
635
- return;
732
+ return 'Successfully initialized: ' + name;
733
+ } catch (e) {
734
+ return 'Failed to initialize: ' + name;
636
735
  }
736
+ }
637
737
 
638
- if (!isObject(config)) {
639
- console.log('\'config\' must be an object. You passed in a ' + typeof config);
640
- return;
641
- }
738
+ function processQueue(queue) {
739
+ var item;
642
740
 
643
- if (isObject(config.kits)) {
644
- config.kits[name] = {
645
- constructor: constructor
646
- };
647
- } else {
648
- config.kits = {};
649
- config.kits[name] = {
650
- constructor: constructor
651
- };
741
+ if (
742
+ (window.gtag || window.google_trackConversion) &&
743
+ queue.length > 0
744
+ ) {
745
+ try {
746
+ while (queue.length > 0) {
747
+ item = queue.shift();
748
+ item.action(item.data);
749
+ }
750
+ } catch (e) {
751
+ console.error('Error on mParticle Adwords Kit', e);
752
+ }
652
753
  }
653
- console.log('Successfully registered ' + name + ' to your mParticle configuration');
654
754
  }
655
755
 
656
- function parseSettingsString(settingsString) {
657
- return JSON.parse(settingsString.replace(/&quot;/g, '"'));
756
+ this.init = initForwarder;
757
+ this.process = processEvent;
758
+ this.processQueue = processQueue;
759
+ };
760
+
761
+ function getId() {
762
+ return moduleId;
763
+ }
764
+
765
+ function register(config) {
766
+ if (!config) {
767
+ console.log(
768
+ 'You must pass a config object to register the kit ' + name
769
+ );
770
+ return;
658
771
  }
659
772
 
660
- function isObject(val) {
661
- return val != null && typeof val === 'object' && Array.isArray(val) === false;
773
+ if (!isObject(config)) {
774
+ console.log(
775
+ "'config' must be an object. You passed in a " + typeof config
776
+ );
777
+ return;
662
778
  }
663
779
 
664
- function isEmpty(value) {
665
- return value == null || !(Object.keys(value) || value).length;
780
+ if (isObject(config.kits)) {
781
+ config.kits[name] = {
782
+ constructor: constructor,
783
+ };
784
+ } else {
785
+ config.kits = {};
786
+ config.kits[name] = {
787
+ constructor: constructor,
788
+ };
666
789
  }
667
-
668
- function mergeObjects() {
669
- var resObj = {};
670
- for(var i=0; i < arguments.length; i += 1) {
671
- var obj = arguments[i],
672
- keys = Object.keys(obj);
673
- for(var j=0; j < keys.length; j += 1) {
674
- resObj[keys[j]] = obj[keys[j]];
675
- }
790
+ console.log(
791
+ 'Successfully registered ' + name + ' to your mParticle configuration'
792
+ );
793
+ }
794
+
795
+ function parseSettingsString(settingsString) {
796
+ return JSON.parse(settingsString.replace(/&quot;/g, '"'));
797
+ }
798
+
799
+ function isObject(val) {
800
+ return (
801
+ val != null && typeof val === 'object' && Array.isArray(val) === false
802
+ );
803
+ }
804
+
805
+ function isEmpty(value) {
806
+ return value == null || !(Object.keys(value) || value).length;
807
+ }
808
+
809
+ function mergeObjects() {
810
+ var resObj = {};
811
+ for (var i = 0; i < arguments.length; i += 1) {
812
+ var obj = arguments[i],
813
+ keys = Object.keys(obj);
814
+ for (var j = 0; j < keys.length; j += 1) {
815
+ resObj[keys[j]] = obj[keys[j]];
676
816
  }
677
- return resObj;
678
- }
679
-
680
- function cloneObject(obj) {
681
- return JSON.parse(JSON.stringify(obj));
682
817
  }
683
-
684
- if (typeof window !== 'undefined') {
685
- if (window && window.mParticle && window.mParticle.addForwarder) {
686
- window.mParticle.addForwarder({
687
- name: name,
688
- constructor: constructor,
689
- getId: getId
690
- });
691
- }
818
+ return resObj;
819
+ }
820
+
821
+ function cloneObject(obj) {
822
+ return JSON.parse(JSON.stringify(obj));
823
+ }
824
+
825
+ if (typeof window !== 'undefined') {
826
+ if (window && window.mParticle && window.mParticle.addForwarder) {
827
+ window.mParticle.addForwarder({
828
+ name: name,
829
+ constructor: constructor,
830
+ getId: getId,
831
+ });
692
832
  }
833
+ }
693
834
 
694
- var GoogleAdWordsEventForwarder = {
695
- register: register
696
- };
835
+ var GoogleAdWordsEventForwarder = {
836
+ register: register,
837
+ };
697
838
 
698
839
  exports.default = GoogleAdWordsEventForwarder;