@walkeros/web-destination-gtag 3.3.1 → 3.4.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.
@@ -36,6 +36,21 @@ declare namespace env {
36
36
  export { env_init as init, env_push as push, env_simulation as simulation };
37
37
  }
38
38
 
39
+ /**
40
+ * GA4 destination bootstrap.
41
+ * Initializes gtag infrastructure and configures the GA4 measurementId.
42
+ */
43
+ declare const ga4Init: Flow.StepExample;
44
+ /**
45
+ * Google Ads destination bootstrap.
46
+ * Initializes gtag infrastructure and configures the Ads conversionId.
47
+ */
48
+ declare const adsInit: Flow.StepExample;
49
+ /**
50
+ * GTM destination bootstrap.
51
+ * Initializes the dataLayer and pushes the gtm.js start event.
52
+ */
53
+ declare const gtmInit: Flow.StepExample;
39
54
  declare const purchase: Flow.StepExample;
40
55
  declare const addToCart: Flow.StepExample;
41
56
  declare const pageView: Flow.StepExample;
@@ -71,7 +86,7 @@ declare const ga4WithIncludeAll: Flow.StepExample;
71
86
  /**
72
87
  * One event pushed to GA4 + Ads + GTM simultaneously.
73
88
  * Shows settings for all three tools in a single mapping rule.
74
- * The out is an object keyed by tool name with each tool's expected output.
89
+ * The out is a flat array of all observable calls in execution order:
75
90
  *
76
91
  * - GA4: gtag('event', eventName, { ...params, send_to })
77
92
  * - Ads: gtag('event', 'conversion', { send_to, currency, ...data })
@@ -80,15 +95,18 @@ declare const ga4WithIncludeAll: Flow.StepExample;
80
95
  declare const multipleToolsSimultaneous: Flow.StepExample;
81
96
 
82
97
  declare const step_addToCart: typeof addToCart;
98
+ declare const step_adsInit: typeof adsInit;
83
99
  declare const step_consentModeV2: typeof consentModeV2;
100
+ declare const step_ga4Init: typeof ga4Init;
84
101
  declare const step_ga4WithIncludeAll: typeof ga4WithIncludeAll;
85
102
  declare const step_googleAdsConversion: typeof googleAdsConversion;
86
103
  declare const step_gtmDataLayerPush: typeof gtmDataLayerPush;
104
+ declare const step_gtmInit: typeof gtmInit;
87
105
  declare const step_multipleToolsSimultaneous: typeof multipleToolsSimultaneous;
88
106
  declare const step_pageView: typeof pageView;
89
107
  declare const step_purchase: typeof purchase;
90
108
  declare namespace step {
91
- export { step_addToCart as addToCart, step_consentModeV2 as consentModeV2, step_ga4WithIncludeAll as ga4WithIncludeAll, step_googleAdsConversion as googleAdsConversion, step_gtmDataLayerPush as gtmDataLayerPush, step_multipleToolsSimultaneous as multipleToolsSimultaneous, step_pageView as pageView, step_purchase as purchase };
109
+ export { step_addToCart as addToCart, step_adsInit as adsInit, step_consentModeV2 as consentModeV2, step_ga4Init as ga4Init, step_ga4WithIncludeAll as ga4WithIncludeAll, step_googleAdsConversion as googleAdsConversion, step_gtmDataLayerPush as gtmDataLayerPush, step_gtmInit as gtmInit, step_multipleToolsSimultaneous as multipleToolsSimultaneous, step_pageView as pageView, step_purchase as purchase };
92
110
  }
93
111
 
94
112
  export { env, step };
@@ -36,6 +36,21 @@ declare namespace env {
36
36
  export { env_init as init, env_push as push, env_simulation as simulation };
37
37
  }
38
38
 
39
+ /**
40
+ * GA4 destination bootstrap.
41
+ * Initializes gtag infrastructure and configures the GA4 measurementId.
42
+ */
43
+ declare const ga4Init: Flow.StepExample;
44
+ /**
45
+ * Google Ads destination bootstrap.
46
+ * Initializes gtag infrastructure and configures the Ads conversionId.
47
+ */
48
+ declare const adsInit: Flow.StepExample;
49
+ /**
50
+ * GTM destination bootstrap.
51
+ * Initializes the dataLayer and pushes the gtm.js start event.
52
+ */
53
+ declare const gtmInit: Flow.StepExample;
39
54
  declare const purchase: Flow.StepExample;
40
55
  declare const addToCart: Flow.StepExample;
41
56
  declare const pageView: Flow.StepExample;
@@ -71,7 +86,7 @@ declare const ga4WithIncludeAll: Flow.StepExample;
71
86
  /**
72
87
  * One event pushed to GA4 + Ads + GTM simultaneously.
73
88
  * Shows settings for all three tools in a single mapping rule.
74
- * The out is an object keyed by tool name with each tool's expected output.
89
+ * The out is a flat array of all observable calls in execution order:
75
90
  *
76
91
  * - GA4: gtag('event', eventName, { ...params, send_to })
77
92
  * - Ads: gtag('event', 'conversion', { send_to, currency, ...data })
@@ -80,15 +95,18 @@ declare const ga4WithIncludeAll: Flow.StepExample;
80
95
  declare const multipleToolsSimultaneous: Flow.StepExample;
81
96
 
82
97
  declare const step_addToCart: typeof addToCart;
98
+ declare const step_adsInit: typeof adsInit;
83
99
  declare const step_consentModeV2: typeof consentModeV2;
100
+ declare const step_ga4Init: typeof ga4Init;
84
101
  declare const step_ga4WithIncludeAll: typeof ga4WithIncludeAll;
85
102
  declare const step_googleAdsConversion: typeof googleAdsConversion;
86
103
  declare const step_gtmDataLayerPush: typeof gtmDataLayerPush;
104
+ declare const step_gtmInit: typeof gtmInit;
87
105
  declare const step_multipleToolsSimultaneous: typeof multipleToolsSimultaneous;
88
106
  declare const step_pageView: typeof pageView;
89
107
  declare const step_purchase: typeof purchase;
90
108
  declare namespace step {
91
- export { step_addToCart as addToCart, step_consentModeV2 as consentModeV2, step_ga4WithIncludeAll as ga4WithIncludeAll, step_googleAdsConversion as googleAdsConversion, step_gtmDataLayerPush as gtmDataLayerPush, step_multipleToolsSimultaneous as multipleToolsSimultaneous, step_pageView as pageView, step_purchase as purchase };
109
+ export { step_addToCart as addToCart, step_adsInit as adsInit, step_consentModeV2 as consentModeV2, step_ga4Init as ga4Init, step_ga4WithIncludeAll as ga4WithIncludeAll, step_googleAdsConversion as googleAdsConversion, step_gtmDataLayerPush as gtmDataLayerPush, step_gtmInit as gtmInit, step_multipleToolsSimultaneous as multipleToolsSimultaneous, step_pageView as pageView, step_purchase as purchase };
92
110
  }
93
111
 
94
112
  export { env, step };
@@ -79,10 +79,13 @@ var simulation = [
79
79
  var step_exports = {};
80
80
  __export(step_exports, {
81
81
  addToCart: () => addToCart,
82
+ adsInit: () => adsInit,
82
83
  consentModeV2: () => consentModeV2,
84
+ ga4Init: () => ga4Init,
83
85
  ga4WithIncludeAll: () => ga4WithIncludeAll,
84
86
  googleAdsConversion: () => googleAdsConversion,
85
87
  gtmDataLayerPush: () => gtmDataLayerPush,
88
+ gtmInit: () => gtmInit,
86
89
  multipleToolsSimultaneous: () => multipleToolsSimultaneous,
87
90
  pageView: () => pageView,
88
91
  purchase: () => purchase
@@ -95,9 +98,9 @@ var c = {};
95
98
  for (var o in n) e(t, o, { get: n[o], enumerable: true });
96
99
  })(c, { Level: () => u });
97
100
  var u = ((e2) => (e2[e2.ERROR = 0] = "ERROR", e2[e2.WARN = 1] = "WARN", e2[e2.INFO = 2] = "INFO", e2[e2.DEBUG = 3] = "DEBUG", e2))(u || {});
98
- var F = { merge: true, shallow: true, extend: true };
101
+ var W = { merge: true, shallow: true, extend: true };
99
102
  function L(e2, t = {}, n = {}) {
100
- n = { ...F, ...n };
103
+ n = { ...W, ...n };
101
104
  const o = Object.entries(t).reduce((t2, [o2, r]) => {
102
105
  const i = e2[o2];
103
106
  return n.merge && Array.isArray(i) && Array.isArray(r) ? t2[o2] = r.reduce((e3, t3) => e3.includes(t3) ? e3 : [...e3, t3], [...i]) : (n.extend || o2 in e2) && (t2[o2] = r), t2;
@@ -112,7 +115,7 @@ function Q(e2) {
112
115
  }
113
116
  function fe(e2 = {}) {
114
117
  var _a;
115
- const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = e2.group || "gr0up", o = e2.count || 1, r = L({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" }, nested: [], context: { element: ["child", 0] } }], consent: { functional: true }, id: `${t}-${n}-${o}`, trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, group: n, count: o, version: { source: "3.3.1", tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
118
+ const t = e2.timestamp || (/* @__PURE__ */ new Date()).setHours(0, 13, 37, 0), n = e2.group || "gr0up", o = e2.count || 1, r = L({ name: "entity action", data: { string: "foo", number: 1, boolean: true, array: [0, "text", false], not: void 0 }, context: { dev: ["test", 1] }, globals: { lang: "elb" }, custom: { completely: "random" }, user: { id: "us3r", device: "c00k13", session: "s3ss10n" }, nested: [{ entity: "child", data: { is: "subordinated" }, nested: [], context: { element: ["child", 0] } }], consent: { functional: true }, id: `${t}-${n}-${o}`, trigger: "test", entity: "entity", action: "action", timestamp: t, timing: 3.14, group: n, count: o, version: { source: "3.4.0", tagging: 1 }, source: { type: "web", id: "https://localhost:80", previous_id: "http://remotehost:9001" } }, e2, { merge: false });
116
119
  if (e2.name) {
117
120
  const [t2, n2] = (_a = e2.name.split(" ")) != null ? _a : [];
118
121
  t2 && n2 && (r.entity = t2, r.action = n2);
@@ -125,6 +128,46 @@ function le(e2 = "entity action", t = {}) {
125
128
  }
126
129
 
127
130
  // src/examples/step.ts
131
+ var INIT_DATE_MS = 17e11;
132
+ var INIT_DATE = new Date(INIT_DATE_MS);
133
+ var ga4Init = {
134
+ in: {
135
+ settings: {
136
+ ga4: { measurementId: "G-XXXXXX-1" }
137
+ }
138
+ },
139
+ out: [
140
+ ["gtag", "js", INIT_DATE],
141
+ ["gtag", "config", "G-XXXXXX-1", {}]
142
+ ]
143
+ };
144
+ var adsInit = {
145
+ in: {
146
+ settings: {
147
+ ads: { conversionId: "AW-123456789", currency: "EUR" }
148
+ }
149
+ },
150
+ out: [
151
+ ["gtag", "js", INIT_DATE],
152
+ ["gtag", "config", "AW-123456789"]
153
+ ]
154
+ };
155
+ var gtmInit = {
156
+ in: {
157
+ settings: {
158
+ gtm: { containerId: "GTM-XXXXXXX" }
159
+ }
160
+ },
161
+ out: [
162
+ [
163
+ "dataLayer.push",
164
+ {
165
+ "gtm.start": INIT_DATE_MS,
166
+ event: "gtm.js"
167
+ }
168
+ ]
169
+ ]
170
+ };
128
171
  var purchase = {
129
172
  in: le("order complete", { timestamp: 1700000100 }),
130
173
  mapping: {
@@ -154,20 +197,30 @@ var purchase = {
154
197
  }
155
198
  },
156
199
  out: [
157
- "event",
158
- "purchase",
159
- {
160
- transaction_id: "0rd3r1d",
161
- value: 555,
162
- tax: 73.76,
163
- shipping: 5.22,
164
- currency: "EUR",
165
- items: [
166
- { item_id: "ers", item_name: "Everyday Ruck Snack", quantity: 1 },
167
- { item_id: "cc", item_name: "Cool Cap", quantity: 1 }
168
- ],
169
- send_to: "G-XXXXXX-1"
170
- }
200
+ [
201
+ "gtag",
202
+ "event",
203
+ "purchase",
204
+ {
205
+ transaction_id: "0rd3r1d",
206
+ value: 555,
207
+ tax: 73.76,
208
+ shipping: 5.22,
209
+ currency: "EUR",
210
+ items: [
211
+ { item_id: "ers", item_name: "Everyday Ruck Snack", quantity: 1 },
212
+ { item_id: "cc", item_name: "Cool Cap", quantity: 1 }
213
+ ],
214
+ // include: ['data', 'context'] flattens both sections as prefixed params.
215
+ data_id: "0rd3r1d",
216
+ data_currency: "EUR",
217
+ data_shipping: 5.22,
218
+ data_taxes: 73.76,
219
+ data_total: 555,
220
+ context_shopping: "complete",
221
+ send_to: "G-XXXXXX-1"
222
+ }
223
+ ]
171
224
  ]
172
225
  };
173
226
  var addToCart = {
@@ -195,20 +248,29 @@ var addToCart = {
195
248
  }
196
249
  },
197
250
  out: [
198
- "event",
199
- "add_to_cart",
200
- {
201
- currency: "EUR",
202
- value: 420,
203
- items: [{ item_id: "ers", item_variant: "black", quantity: 1 }],
204
- send_to: "G-XXXXXX-1"
205
- }
251
+ [
252
+ "gtag",
253
+ "event",
254
+ "add_to_cart",
255
+ {
256
+ currency: "EUR",
257
+ value: 420,
258
+ items: [{ item_id: "ers", item_variant: "black", quantity: 1 }],
259
+ // include: ['data'] flattens data as prefixed params.
260
+ data_id: "ers",
261
+ data_name: "Everyday Ruck Snack",
262
+ data_color: "black",
263
+ data_size: "l",
264
+ data_price: 420,
265
+ send_to: "G-XXXXXX-1"
266
+ }
267
+ ]
206
268
  ]
207
269
  };
208
270
  var pageView = {
209
271
  in: le("page view", { timestamp: 1700000102 }),
210
272
  mapping: void 0,
211
- out: ["event", "page_view", { send_to: "G-XXXXXX-1" }]
273
+ out: [["gtag", "event", "page_view", { send_to: "G-XXXXXX-1" }]]
212
274
  };
213
275
  var googleAdsConversion = {
214
276
  in: le("order complete", { timestamp: 1700000103 }),
@@ -224,13 +286,16 @@ var googleAdsConversion = {
224
286
  }
225
287
  },
226
288
  out: [
227
- "event",
228
- "conversion",
229
- {
230
- send_to: "AW-123456789/PURCHASE_CONV",
231
- currency: "EUR",
232
- value: 555
233
- }
289
+ [
290
+ "gtag",
291
+ "event",
292
+ "conversion",
293
+ {
294
+ send_to: "AW-123456789/PURCHASE_CONV",
295
+ currency: "EUR",
296
+ value: 555
297
+ }
298
+ ]
234
299
  ]
235
300
  };
236
301
  var gtmDataLayerPush = {
@@ -247,24 +312,44 @@ var gtmDataLayerPush = {
247
312
  }
248
313
  }
249
314
  },
250
- out: {
251
- event: "page_view",
252
- page_title: "walkerOS documentation",
253
- page_location: "www.example.com"
254
- }
315
+ out: [
316
+ [
317
+ "dataLayer.push",
318
+ {
319
+ event: "page_view",
320
+ page_title: "walkerOS documentation",
321
+ page_location: "www.example.com"
322
+ }
323
+ ]
324
+ ]
255
325
  };
256
326
  var consentModeV2 = {
257
327
  command: "consent",
258
328
  in: { marketing: true, functional: true },
259
329
  out: [
260
- "consent",
261
- "update",
262
- {
263
- ad_storage: "granted",
264
- ad_user_data: "granted",
265
- ad_personalization: "granted",
266
- analytics_storage: "granted"
267
- }
330
+ // First consent call sets default to denied for all mapped parameters.
331
+ [
332
+ "gtag",
333
+ "consent",
334
+ "default",
335
+ {
336
+ ad_storage: "denied",
337
+ ad_user_data: "denied",
338
+ ad_personalization: "denied",
339
+ analytics_storage: "denied"
340
+ }
341
+ ],
342
+ [
343
+ "gtag",
344
+ "consent",
345
+ "update",
346
+ {
347
+ ad_storage: "granted",
348
+ ad_user_data: "granted",
349
+ ad_personalization: "granted",
350
+ analytics_storage: "granted"
351
+ }
352
+ ]
268
353
  ]
269
354
  };
270
355
  var ga4WithIncludeAll = {
@@ -273,37 +358,47 @@ var ga4WithIncludeAll = {
273
358
  include: ["all"]
274
359
  },
275
360
  out: [
276
- "event",
277
- "page_view",
278
- {
279
- // data_* params from event.data
280
- data_domain: "www.example.com",
281
- data_title: "walkerOS documentation",
282
- data_referrer: "https://www.walkeros.io/",
283
- data_search: "?foo=bar",
284
- data_hash: "#hash",
285
- data_id: "/docs/",
286
- // context_* params from event.context
287
- context_dev: "test",
288
- // globals_* params from event.globals
289
- globals_pagegroup: "docs",
290
- // user_* params from event.user
291
- user_id: "us3r",
292
- user_device: "c00k13",
293
- user_session: "s3ss10n",
294
- // source_* params from event.source
295
- source_type: "web",
296
- source_id: "https://localhost:80",
297
- source_previous_id: "http://remotehost:9001",
298
- // event_* params from event properties
299
- event_entity: "page",
300
- event_action: "view",
301
- event_trigger: "load",
302
- event_group: "gr0up",
303
- event_count: 1,
304
- // send_to is always set for GA4
305
- send_to: "G-XXXXXX-1"
306
- }
361
+ [
362
+ "gtag",
363
+ "event",
364
+ "page_view",
365
+ {
366
+ // data_* params from event.data
367
+ data_domain: "www.example.com",
368
+ data_title: "walkerOS documentation",
369
+ data_referrer: "https://www.walkeros.io/",
370
+ data_search: "?foo=bar",
371
+ data_hash: "#hash",
372
+ data_id: "/docs/",
373
+ // context_* params from event.context
374
+ context_dev: "test",
375
+ // globals_* params from event.globals
376
+ globals_pagegroup: "docs",
377
+ // user_* params from event.user
378
+ user_id: "us3r",
379
+ user_device: "c00k13",
380
+ user_session: "s3ss10n",
381
+ // source_* params from event.source
382
+ source_type: "web",
383
+ source_id: "https://localhost:80",
384
+ source_previous_id: "http://remotehost:9001",
385
+ // event_* params from event properties
386
+ event_entity: "page",
387
+ event_action: "view",
388
+ event_trigger: "load",
389
+ event_group: "gr0up",
390
+ event_count: 1,
391
+ event_id: "1700000106-gr0up-1",
392
+ event_name: "page view",
393
+ event_timestamp: 1700000106,
394
+ event_timing: 3.14,
395
+ // version_* params from event.version
396
+ version_source: "3.3.1",
397
+ version_tagging: 1,
398
+ // send_to is always set for GA4
399
+ send_to: "G-XXXXXX-1"
400
+ }
401
+ ]
307
402
  ]
308
403
  };
309
404
  var multipleToolsSimultaneous = {
@@ -323,31 +418,52 @@ var multipleToolsSimultaneous = {
323
418
  }
324
419
  }
325
420
  },
326
- out: {
327
- ga4: [
421
+ out: [
422
+ [
423
+ "gtag",
328
424
  "event",
329
425
  "purchase",
330
426
  {
331
427
  value: 555,
332
428
  currency: "EUR",
429
+ // include: ['data'] flattens data as prefixed params.
430
+ data_id: "0rd3r1d",
431
+ data_currency: "EUR",
432
+ data_shipping: 5.22,
433
+ data_taxes: 73.76,
434
+ data_total: 555,
333
435
  send_to: "G-XXXXXX-1"
334
436
  }
335
437
  ],
336
- ads: [
438
+ [
439
+ "gtag",
337
440
  "event",
338
441
  "conversion",
339
442
  {
340
443
  send_to: "AW-123456789/PURCHASE_CONV",
341
444
  currency: "EUR",
342
- value: 555
445
+ value: 555,
446
+ data_id: "0rd3r1d",
447
+ data_currency: "EUR",
448
+ data_shipping: 5.22,
449
+ data_taxes: 73.76,
450
+ data_total: 555
343
451
  }
344
452
  ],
345
- gtm: {
346
- event: "purchase",
347
- value: 555,
348
- currency: "EUR"
349
- }
350
- }
453
+ [
454
+ "dataLayer.push",
455
+ {
456
+ event: "purchase",
457
+ value: 555,
458
+ currency: "EUR",
459
+ data_id: "0rd3r1d",
460
+ data_currency: "EUR",
461
+ data_shipping: 5.22,
462
+ data_taxes: 73.76,
463
+ data_total: 555
464
+ }
465
+ ]
466
+ ]
351
467
  };
352
468
  // Annotate the CommonJS export names for ESM import in node:
353
469
  0 && (module.exports = {