@walkeros/web-source-datalayer 2.0.1 → 2.1.1
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.
- package/dist/dev.d.mts +48 -7
- package/dist/dev.d.ts +48 -7
- package/dist/dev.js +1 -1
- package/dist/dev.js.map +1 -1
- package/dist/dev.mjs +1 -1
- package/dist/dev.mjs.map +1 -1
- package/dist/examples/index.d.mts +12 -77
- package/dist/examples/index.d.ts +12 -77
- package/dist/examples/index.js +64 -243
- package/dist/examples/index.mjs +61 -237
- package/dist/index.browser.js +1 -1
- package/dist/index.d.mts +12 -77
- package/dist/index.d.ts +12 -77
- package/dist/index.es5.js +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/walkerOS.json +125 -3
- package/package.json +5 -4
package/dist/examples/index.js
CHANGED
|
@@ -20,12 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/examples/index.ts
|
|
21
21
|
var examples_exports = {};
|
|
22
22
|
__export(examples_exports, {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
consentUpdateEvent: () => consentUpdate,
|
|
27
|
-
dataLayerExamples: () => config2,
|
|
28
|
-
env: () => env_exports
|
|
23
|
+
env: () => env_exports,
|
|
24
|
+
setup: () => setup,
|
|
25
|
+
step: () => step_exports
|
|
29
26
|
});
|
|
30
27
|
module.exports = __toCommonJS(examples_exports);
|
|
31
28
|
|
|
@@ -44,11 +41,13 @@ var createMockElbFn = () => {
|
|
|
44
41
|
};
|
|
45
42
|
var noopLogger = {
|
|
46
43
|
error: noop,
|
|
44
|
+
warn: noop,
|
|
47
45
|
info: noop,
|
|
48
46
|
debug: noop,
|
|
49
47
|
throw: (message) => {
|
|
50
48
|
throw typeof message === "string" ? new Error(message) : message;
|
|
51
49
|
},
|
|
50
|
+
json: noop,
|
|
52
51
|
scope: () => noopLogger
|
|
53
52
|
};
|
|
54
53
|
var createMockWindow = () => ({
|
|
@@ -72,263 +71,85 @@ var push = {
|
|
|
72
71
|
logger: noopLogger
|
|
73
72
|
};
|
|
74
73
|
|
|
75
|
-
// src/examples/
|
|
76
|
-
var
|
|
77
|
-
__export(
|
|
78
|
-
add_to_cart: () => add_to_cart,
|
|
79
|
-
config: () => config,
|
|
80
|
-
consentDefault: () => consentDefault,
|
|
74
|
+
// src/examples/step.ts
|
|
75
|
+
var step_exports = {};
|
|
76
|
+
__export(step_exports, {
|
|
81
77
|
consentUpdate: () => consentUpdate,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
setCustom: () => setCustom,
|
|
85
|
-
view_item: () => view_item
|
|
78
|
+
directEvent: () => directEvent,
|
|
79
|
+
gtagPurchase: () => gtagPurchase
|
|
86
80
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"consent",
|
|
90
|
-
"update",
|
|
91
|
-
{
|
|
92
|
-
ad_user_data: "granted",
|
|
93
|
-
ad_personalization: "granted",
|
|
94
|
-
ad_storage: "denied",
|
|
95
|
-
analytics_storage: "granted"
|
|
96
|
-
}
|
|
97
|
-
];
|
|
98
|
-
}
|
|
99
|
-
function consentDefault() {
|
|
100
|
-
return [
|
|
101
|
-
"consent",
|
|
102
|
-
"default",
|
|
103
|
-
{
|
|
104
|
-
ad_storage: "denied",
|
|
105
|
-
analytics_storage: "denied",
|
|
106
|
-
ad_user_data: "denied",
|
|
107
|
-
ad_personalization: "denied"
|
|
108
|
-
}
|
|
109
|
-
];
|
|
110
|
-
}
|
|
111
|
-
function purchase() {
|
|
112
|
-
return [
|
|
81
|
+
var gtagPurchase = {
|
|
82
|
+
in: [
|
|
113
83
|
"event",
|
|
114
84
|
"purchase",
|
|
115
85
|
{
|
|
116
|
-
transaction_id: "
|
|
86
|
+
transaction_id: "T-12345",
|
|
117
87
|
value: 25.42,
|
|
118
88
|
currency: "EUR",
|
|
119
|
-
items: [
|
|
120
|
-
{
|
|
121
|
-
item_id: "SKU_12345",
|
|
122
|
-
item_name: "Product Name",
|
|
123
|
-
item_category: "Category",
|
|
124
|
-
quantity: 1,
|
|
125
|
-
price: 25.42
|
|
126
|
-
}
|
|
127
|
-
]
|
|
128
|
-
}
|
|
129
|
-
];
|
|
130
|
-
}
|
|
131
|
-
function add_to_cart() {
|
|
132
|
-
return [
|
|
133
|
-
"event",
|
|
134
|
-
"add_to_cart",
|
|
135
|
-
{
|
|
136
|
-
currency: "EUR",
|
|
137
|
-
value: 15.25,
|
|
138
|
-
items: [
|
|
139
|
-
{
|
|
140
|
-
item_id: "SKU_12345",
|
|
141
|
-
item_name: "Product Name",
|
|
142
|
-
item_variant: "red",
|
|
143
|
-
quantity: 1,
|
|
144
|
-
price: 15.25
|
|
145
|
-
}
|
|
146
|
-
]
|
|
89
|
+
items: [{ item_id: "SKU-1", item_name: "T-Shirt", quantity: 1 }]
|
|
147
90
|
}
|
|
148
|
-
]
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
{
|
|
155
|
-
currency: "EUR",
|
|
156
|
-
value: 15.25,
|
|
157
|
-
items: [
|
|
158
|
-
{
|
|
159
|
-
item_id: "SKU_12345",
|
|
160
|
-
item_name: "Product Name",
|
|
161
|
-
item_category: "Category",
|
|
162
|
-
price: 15.25
|
|
163
|
-
}
|
|
164
|
-
]
|
|
165
|
-
}
|
|
166
|
-
];
|
|
167
|
-
}
|
|
168
|
-
function config() {
|
|
169
|
-
return [
|
|
170
|
-
"config",
|
|
171
|
-
"G-XXXXXXXXXX",
|
|
172
|
-
{
|
|
173
|
-
page_title: "Custom Page Title",
|
|
174
|
-
page_location: "https://example.com/page",
|
|
175
|
-
send_page_view: false
|
|
176
|
-
}
|
|
177
|
-
];
|
|
178
|
-
}
|
|
179
|
-
function setCustom() {
|
|
180
|
-
return [
|
|
181
|
-
"set",
|
|
182
|
-
{
|
|
91
|
+
],
|
|
92
|
+
out: {
|
|
93
|
+
name: "dataLayer purchase",
|
|
94
|
+
data: {
|
|
95
|
+
transaction_id: "T-12345",
|
|
96
|
+
value: 25.42,
|
|
183
97
|
currency: "EUR",
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
function directDataLayerEvent() {
|
|
189
|
-
return {
|
|
190
|
-
event: "custom_event",
|
|
191
|
-
custom_parameter: "custom_value",
|
|
192
|
-
user_id: "user123"
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// src/examples/mapping.ts
|
|
197
|
-
var mapping_exports = {};
|
|
198
|
-
__export(mapping_exports, {
|
|
199
|
-
add_to_cart: () => add_to_cart2,
|
|
200
|
-
config: () => config2,
|
|
201
|
-
configGA4: () => configGA4,
|
|
202
|
-
consentOnlyMapping: () => consentOnlyMapping,
|
|
203
|
-
consentUpdate: () => consentUpdate2,
|
|
204
|
-
customEvent: () => customEvent,
|
|
205
|
-
purchase: () => purchase2,
|
|
206
|
-
view_item: () => view_item2
|
|
207
|
-
});
|
|
208
|
-
var consentUpdate2 = {
|
|
209
|
-
name: "walker consent",
|
|
210
|
-
settings: {
|
|
211
|
-
command: {
|
|
212
|
-
map: {
|
|
213
|
-
functional: { value: true },
|
|
214
|
-
// Static value - always true for functional
|
|
215
|
-
analytics: {
|
|
216
|
-
key: "analytics_storage",
|
|
217
|
-
fn: (value) => value === "granted"
|
|
218
|
-
},
|
|
219
|
-
marketing: {
|
|
220
|
-
key: "ad_storage",
|
|
221
|
-
fn: (value) => value === "granted"
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
var purchase2 = {
|
|
228
|
-
name: "order complete",
|
|
229
|
-
data: {
|
|
230
|
-
map: {
|
|
231
|
-
id: "transaction_id",
|
|
232
|
-
total: "value",
|
|
233
|
-
currency: "currency",
|
|
234
|
-
nested: {
|
|
235
|
-
loop: [
|
|
236
|
-
"items",
|
|
237
|
-
{
|
|
238
|
-
map: {
|
|
239
|
-
type: { value: "product" },
|
|
240
|
-
data: {
|
|
241
|
-
map: {
|
|
242
|
-
id: "item_id",
|
|
243
|
-
name: "item_name",
|
|
244
|
-
category: "item_category",
|
|
245
|
-
quantity: "quantity",
|
|
246
|
-
price: "price"
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
]
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
};
|
|
256
|
-
var add_to_cart2 = {
|
|
257
|
-
name: "product add",
|
|
258
|
-
data: {
|
|
259
|
-
map: {
|
|
260
|
-
id: "items.0.item_id",
|
|
261
|
-
name: "items.0.item_name",
|
|
262
|
-
price: "value",
|
|
263
|
-
currency: "currency",
|
|
264
|
-
color: "items.0.item_variant",
|
|
265
|
-
quantity: "items.0.quantity"
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
};
|
|
269
|
-
var view_item2 = {
|
|
270
|
-
name: "product view",
|
|
271
|
-
data: {
|
|
272
|
-
map: {
|
|
273
|
-
id: "items.0.item_id",
|
|
274
|
-
name: "items.0.item_name",
|
|
275
|
-
category: "items.0.item_category",
|
|
276
|
-
price: "items.0.price",
|
|
277
|
-
currency: "currency"
|
|
278
|
-
}
|
|
98
|
+
items: [{ item_id: "SKU-1", item_name: "T-Shirt", quantity: 1 }]
|
|
99
|
+
},
|
|
100
|
+
entity: "dataLayer",
|
|
101
|
+
action: "purchase"
|
|
279
102
|
}
|
|
280
103
|
};
|
|
281
|
-
var
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
}
|
|
289
|
-
};
|
|
290
|
-
var customEvent = {
|
|
291
|
-
// Keep original event name with gtag prefix
|
|
292
|
-
data: {
|
|
293
|
-
map: {
|
|
294
|
-
// Map all properties as-is
|
|
295
|
-
user_id: "user_id",
|
|
296
|
-
custom_parameter: "custom_parameter"
|
|
104
|
+
var consentUpdate = {
|
|
105
|
+
in: [
|
|
106
|
+
"consent",
|
|
107
|
+
"update",
|
|
108
|
+
{
|
|
109
|
+
ad_storage: "granted",
|
|
110
|
+
analytics_storage: "granted"
|
|
297
111
|
}
|
|
112
|
+
],
|
|
113
|
+
out: {
|
|
114
|
+
name: "dataLayer consent update",
|
|
115
|
+
data: {
|
|
116
|
+
ad_storage: "granted",
|
|
117
|
+
analytics_storage: "granted"
|
|
118
|
+
},
|
|
119
|
+
entity: "dataLayer",
|
|
120
|
+
action: "consent update"
|
|
298
121
|
}
|
|
299
122
|
};
|
|
300
|
-
var
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
123
|
+
var directEvent = {
|
|
124
|
+
in: {
|
|
125
|
+
event: "custom_event",
|
|
126
|
+
category: "engagement",
|
|
127
|
+
label: "video_play"
|
|
304
128
|
},
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
add_to_cart: add_to_cart2,
|
|
308
|
-
view_item: view_item2,
|
|
309
|
-
// Config events
|
|
310
|
-
"config G-XXXXXXXXXX": configGA4,
|
|
311
|
-
// Custom events
|
|
312
|
-
custom_event: customEvent,
|
|
313
|
-
// Catch-all for unmapped events
|
|
314
|
-
"*": {
|
|
315
|
-
// Pass through with gtag prefix
|
|
129
|
+
out: {
|
|
130
|
+
name: "dataLayer custom_event",
|
|
316
131
|
data: {
|
|
317
|
-
|
|
318
|
-
|
|
132
|
+
category: "engagement",
|
|
133
|
+
label: "video_play"
|
|
134
|
+
},
|
|
135
|
+
entity: "dataLayer",
|
|
136
|
+
action: "custom_event"
|
|
319
137
|
}
|
|
320
138
|
};
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
139
|
+
|
|
140
|
+
// src/examples/setup.ts
|
|
141
|
+
var setup = (input, env) => {
|
|
142
|
+
const win = env.window;
|
|
143
|
+
if (!win.dataLayer) win.dataLayer = [];
|
|
144
|
+
if (Array.isArray(input)) {
|
|
145
|
+
for (const item of input) win.dataLayer.push(item);
|
|
146
|
+
} else if (input && typeof input === "object") {
|
|
147
|
+
win.dataLayer.push(input);
|
|
324
148
|
}
|
|
325
149
|
};
|
|
326
150
|
// Annotate the CommonJS export names for ESM import in node:
|
|
327
151
|
0 && (module.exports = {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
consentUpdateEvent,
|
|
332
|
-
dataLayerExamples,
|
|
333
|
-
env
|
|
152
|
+
env,
|
|
153
|
+
setup,
|
|
154
|
+
step
|
|
334
155
|
});
|
package/dist/examples/index.mjs
CHANGED
|
@@ -19,11 +19,13 @@ var createMockElbFn = () => {
|
|
|
19
19
|
};
|
|
20
20
|
var noopLogger = {
|
|
21
21
|
error: noop,
|
|
22
|
+
warn: noop,
|
|
22
23
|
info: noop,
|
|
23
24
|
debug: noop,
|
|
24
25
|
throw: (message) => {
|
|
25
26
|
throw typeof message === "string" ? new Error(message) : message;
|
|
26
27
|
},
|
|
28
|
+
json: noop,
|
|
27
29
|
scope: () => noopLogger
|
|
28
30
|
};
|
|
29
31
|
var createMockWindow = () => ({
|
|
@@ -47,262 +49,84 @@ var push = {
|
|
|
47
49
|
logger: noopLogger
|
|
48
50
|
};
|
|
49
51
|
|
|
50
|
-
// src/examples/
|
|
51
|
-
var
|
|
52
|
-
__export(
|
|
53
|
-
add_to_cart: () => add_to_cart,
|
|
54
|
-
config: () => config,
|
|
55
|
-
consentDefault: () => consentDefault,
|
|
52
|
+
// src/examples/step.ts
|
|
53
|
+
var step_exports = {};
|
|
54
|
+
__export(step_exports, {
|
|
56
55
|
consentUpdate: () => consentUpdate,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
setCustom: () => setCustom,
|
|
60
|
-
view_item: () => view_item
|
|
56
|
+
directEvent: () => directEvent,
|
|
57
|
+
gtagPurchase: () => gtagPurchase
|
|
61
58
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
"consent",
|
|
65
|
-
"update",
|
|
66
|
-
{
|
|
67
|
-
ad_user_data: "granted",
|
|
68
|
-
ad_personalization: "granted",
|
|
69
|
-
ad_storage: "denied",
|
|
70
|
-
analytics_storage: "granted"
|
|
71
|
-
}
|
|
72
|
-
];
|
|
73
|
-
}
|
|
74
|
-
function consentDefault() {
|
|
75
|
-
return [
|
|
76
|
-
"consent",
|
|
77
|
-
"default",
|
|
78
|
-
{
|
|
79
|
-
ad_storage: "denied",
|
|
80
|
-
analytics_storage: "denied",
|
|
81
|
-
ad_user_data: "denied",
|
|
82
|
-
ad_personalization: "denied"
|
|
83
|
-
}
|
|
84
|
-
];
|
|
85
|
-
}
|
|
86
|
-
function purchase() {
|
|
87
|
-
return [
|
|
59
|
+
var gtagPurchase = {
|
|
60
|
+
in: [
|
|
88
61
|
"event",
|
|
89
62
|
"purchase",
|
|
90
63
|
{
|
|
91
|
-
transaction_id: "
|
|
64
|
+
transaction_id: "T-12345",
|
|
92
65
|
value: 25.42,
|
|
93
66
|
currency: "EUR",
|
|
94
|
-
items: [
|
|
95
|
-
{
|
|
96
|
-
item_id: "SKU_12345",
|
|
97
|
-
item_name: "Product Name",
|
|
98
|
-
item_category: "Category",
|
|
99
|
-
quantity: 1,
|
|
100
|
-
price: 25.42
|
|
101
|
-
}
|
|
102
|
-
]
|
|
103
|
-
}
|
|
104
|
-
];
|
|
105
|
-
}
|
|
106
|
-
function add_to_cart() {
|
|
107
|
-
return [
|
|
108
|
-
"event",
|
|
109
|
-
"add_to_cart",
|
|
110
|
-
{
|
|
111
|
-
currency: "EUR",
|
|
112
|
-
value: 15.25,
|
|
113
|
-
items: [
|
|
114
|
-
{
|
|
115
|
-
item_id: "SKU_12345",
|
|
116
|
-
item_name: "Product Name",
|
|
117
|
-
item_variant: "red",
|
|
118
|
-
quantity: 1,
|
|
119
|
-
price: 15.25
|
|
120
|
-
}
|
|
121
|
-
]
|
|
67
|
+
items: [{ item_id: "SKU-1", item_name: "T-Shirt", quantity: 1 }]
|
|
122
68
|
}
|
|
123
|
-
]
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
{
|
|
130
|
-
currency: "EUR",
|
|
131
|
-
value: 15.25,
|
|
132
|
-
items: [
|
|
133
|
-
{
|
|
134
|
-
item_id: "SKU_12345",
|
|
135
|
-
item_name: "Product Name",
|
|
136
|
-
item_category: "Category",
|
|
137
|
-
price: 15.25
|
|
138
|
-
}
|
|
139
|
-
]
|
|
140
|
-
}
|
|
141
|
-
];
|
|
142
|
-
}
|
|
143
|
-
function config() {
|
|
144
|
-
return [
|
|
145
|
-
"config",
|
|
146
|
-
"G-XXXXXXXXXX",
|
|
147
|
-
{
|
|
148
|
-
page_title: "Custom Page Title",
|
|
149
|
-
page_location: "https://example.com/page",
|
|
150
|
-
send_page_view: false
|
|
151
|
-
}
|
|
152
|
-
];
|
|
153
|
-
}
|
|
154
|
-
function setCustom() {
|
|
155
|
-
return [
|
|
156
|
-
"set",
|
|
157
|
-
{
|
|
69
|
+
],
|
|
70
|
+
out: {
|
|
71
|
+
name: "dataLayer purchase",
|
|
72
|
+
data: {
|
|
73
|
+
transaction_id: "T-12345",
|
|
74
|
+
value: 25.42,
|
|
158
75
|
currency: "EUR",
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
function directDataLayerEvent() {
|
|
164
|
-
return {
|
|
165
|
-
event: "custom_event",
|
|
166
|
-
custom_parameter: "custom_value",
|
|
167
|
-
user_id: "user123"
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// src/examples/mapping.ts
|
|
172
|
-
var mapping_exports = {};
|
|
173
|
-
__export(mapping_exports, {
|
|
174
|
-
add_to_cart: () => add_to_cart2,
|
|
175
|
-
config: () => config2,
|
|
176
|
-
configGA4: () => configGA4,
|
|
177
|
-
consentOnlyMapping: () => consentOnlyMapping,
|
|
178
|
-
consentUpdate: () => consentUpdate2,
|
|
179
|
-
customEvent: () => customEvent,
|
|
180
|
-
purchase: () => purchase2,
|
|
181
|
-
view_item: () => view_item2
|
|
182
|
-
});
|
|
183
|
-
var consentUpdate2 = {
|
|
184
|
-
name: "walker consent",
|
|
185
|
-
settings: {
|
|
186
|
-
command: {
|
|
187
|
-
map: {
|
|
188
|
-
functional: { value: true },
|
|
189
|
-
// Static value - always true for functional
|
|
190
|
-
analytics: {
|
|
191
|
-
key: "analytics_storage",
|
|
192
|
-
fn: (value) => value === "granted"
|
|
193
|
-
},
|
|
194
|
-
marketing: {
|
|
195
|
-
key: "ad_storage",
|
|
196
|
-
fn: (value) => value === "granted"
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
var purchase2 = {
|
|
203
|
-
name: "order complete",
|
|
204
|
-
data: {
|
|
205
|
-
map: {
|
|
206
|
-
id: "transaction_id",
|
|
207
|
-
total: "value",
|
|
208
|
-
currency: "currency",
|
|
209
|
-
nested: {
|
|
210
|
-
loop: [
|
|
211
|
-
"items",
|
|
212
|
-
{
|
|
213
|
-
map: {
|
|
214
|
-
type: { value: "product" },
|
|
215
|
-
data: {
|
|
216
|
-
map: {
|
|
217
|
-
id: "item_id",
|
|
218
|
-
name: "item_name",
|
|
219
|
-
category: "item_category",
|
|
220
|
-
quantity: "quantity",
|
|
221
|
-
price: "price"
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
]
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
var add_to_cart2 = {
|
|
232
|
-
name: "product add",
|
|
233
|
-
data: {
|
|
234
|
-
map: {
|
|
235
|
-
id: "items.0.item_id",
|
|
236
|
-
name: "items.0.item_name",
|
|
237
|
-
price: "value",
|
|
238
|
-
currency: "currency",
|
|
239
|
-
color: "items.0.item_variant",
|
|
240
|
-
quantity: "items.0.quantity"
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
var view_item2 = {
|
|
245
|
-
name: "product view",
|
|
246
|
-
data: {
|
|
247
|
-
map: {
|
|
248
|
-
id: "items.0.item_id",
|
|
249
|
-
name: "items.0.item_name",
|
|
250
|
-
category: "items.0.item_category",
|
|
251
|
-
price: "items.0.price",
|
|
252
|
-
currency: "currency"
|
|
253
|
-
}
|
|
76
|
+
items: [{ item_id: "SKU-1", item_name: "T-Shirt", quantity: 1 }]
|
|
77
|
+
},
|
|
78
|
+
entity: "dataLayer",
|
|
79
|
+
action: "purchase"
|
|
254
80
|
}
|
|
255
81
|
};
|
|
256
|
-
var
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
var customEvent = {
|
|
266
|
-
// Keep original event name with gtag prefix
|
|
267
|
-
data: {
|
|
268
|
-
map: {
|
|
269
|
-
// Map all properties as-is
|
|
270
|
-
user_id: "user_id",
|
|
271
|
-
custom_parameter: "custom_parameter"
|
|
82
|
+
var consentUpdate = {
|
|
83
|
+
in: [
|
|
84
|
+
"consent",
|
|
85
|
+
"update",
|
|
86
|
+
{
|
|
87
|
+
ad_storage: "granted",
|
|
88
|
+
analytics_storage: "granted"
|
|
272
89
|
}
|
|
90
|
+
],
|
|
91
|
+
out: {
|
|
92
|
+
name: "dataLayer consent update",
|
|
93
|
+
data: {
|
|
94
|
+
ad_storage: "granted",
|
|
95
|
+
analytics_storage: "granted"
|
|
96
|
+
},
|
|
97
|
+
entity: "dataLayer",
|
|
98
|
+
action: "consent update"
|
|
273
99
|
}
|
|
274
100
|
};
|
|
275
|
-
var
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
101
|
+
var directEvent = {
|
|
102
|
+
in: {
|
|
103
|
+
event: "custom_event",
|
|
104
|
+
category: "engagement",
|
|
105
|
+
label: "video_play"
|
|
279
106
|
},
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
add_to_cart: add_to_cart2,
|
|
283
|
-
view_item: view_item2,
|
|
284
|
-
// Config events
|
|
285
|
-
"config G-XXXXXXXXXX": configGA4,
|
|
286
|
-
// Custom events
|
|
287
|
-
custom_event: customEvent,
|
|
288
|
-
// Catch-all for unmapped events
|
|
289
|
-
"*": {
|
|
290
|
-
// Pass through with gtag prefix
|
|
107
|
+
out: {
|
|
108
|
+
name: "dataLayer custom_event",
|
|
291
109
|
data: {
|
|
292
|
-
|
|
293
|
-
|
|
110
|
+
category: "engagement",
|
|
111
|
+
label: "video_play"
|
|
112
|
+
},
|
|
113
|
+
entity: "dataLayer",
|
|
114
|
+
action: "custom_event"
|
|
294
115
|
}
|
|
295
116
|
};
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
117
|
+
|
|
118
|
+
// src/examples/setup.ts
|
|
119
|
+
var setup = (input, env) => {
|
|
120
|
+
const win = env.window;
|
|
121
|
+
if (!win.dataLayer) win.dataLayer = [];
|
|
122
|
+
if (Array.isArray(input)) {
|
|
123
|
+
for (const item of input) win.dataLayer.push(item);
|
|
124
|
+
} else if (input && typeof input === "object") {
|
|
125
|
+
win.dataLayer.push(input);
|
|
299
126
|
}
|
|
300
127
|
};
|
|
301
128
|
export {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
consentUpdate as consentUpdateEvent,
|
|
306
|
-
config2 as dataLayerExamples,
|
|
307
|
-
env_exports as env
|
|
129
|
+
env_exports as env,
|
|
130
|
+
setup,
|
|
131
|
+
step_exports as step
|
|
308
132
|
};
|