-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.tpl
419 lines (388 loc) · 14.5 KB
/
template.tpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
___TERMS_OF_SERVICE___
By creating or modifying this file you agree to Google Tag Manager's Community
Template Gallery Developer Terms of Service available at
https://developers.google.com/tag-manager/gallery-tos (or such other URL as
Google may provide), as modified from time to time.
___INFO___
{
"type": "TAG",
"id": "cvt_temp_public_id",
"version": 1,
"securityGroups": [],
"displayName": "DataLayer Event Repeater",
"categories": [
"UTILITY"
],
"brand": {
"id": "brand_dummy",
"displayName": "",
"thumbnail": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5wsMACEuqtoXHwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAdkSURBVFjDpVdrVFTXFf7OvTPDzMAMb3nIGx9QqGiFJjEoCYimqEkjwbRi1IUYE81qUo0kTbu6uhq1cZmWlcTGF0SkpDwjaiqJtYpJlw8QERQQIu+qOCADzjB3hpl77+kPJM5lCILZ/+7e++7znf0+BJOkDW+8pers6EnR3zcmymTMfF4QZ4gCdSeEgmWYQYZBG6Wk1tlZfiYqYvbJT7N3c5OxSx6lsOSFl/2MQ5Yss8WaYbXyWjoJg3IZMWjUyjyt1nl3RXnhnccCkPn627LWzo53Bw3ce8NWXoUpE4WTjDGr1YqdUZEzdx/am81PGsDytHQ/vX6ofNDAPUHx44gA8NA6V3l7uaaWFx+5PVbOjmUkLEkN7x80/NdoGo56lOWiggNQyoFrjd9NqGoetgUMGYdemjEr8svuju8G7GWM/ceylem+BhN3xmzhg37IrfY3mzbNC+sz1uOnEaGP9ISFp0G8SCvT0jP9xgXw/gcfyvr0g19YrLbgsT+7aVT4w7tbUF52BCtXJI1AISMgXFw02LzlVQBAWLAfykvzsONP2+DtqXUAYTBZAzu6bpXs2JMtcwBwuvL8O0aTdYF9WhAAKYufxucFOVixYgVMpiG0tXcAoCAPnEGpiOqqSwAAXd8A+np1SFqcjPz8g1i+dKEkySgAbliIr/j6bJYkB1LXZAT26AZKBZHK7BGvfikFW7dthSAI2Pfpfvx518fQ9Q0AICAEWLtmFaqrqrEn+xAAwGbj8a+K/6D3bjdiY2ORmPQshjkDGhpvSjxhswlPJSUv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LWpOLRvz5iypIiJCsfh3E8QFRWNE8ePI7/oS2nCEohqlWLX9/tAa3NDb2RUjK/JYo2zV7xw8QqUcmDBgqeRsmwpQoP8cOFiDQRRxPyY2cjavg1yhROKSo6CZYFfJMfj9U3rkbkxA1qtFsWFhfjrx7kO/dFdq9z37aljeQAeZoyvj2eWwcQ9Y7EKkfZ9fO+Bz1FTU4dXX8tA8pJknKv8FufO1+KNLZugUqsgd1Lg9FdlUKqcIJcpIIg2NDY2ITfnCC7VNDocrlSwLZ4emnfGbe/Pp62LuNXTd8E8bHMfL7nUaieYuGEAQNZbmUhdlQaOs+BmSzM4jkNHZydOnTqD5tZb4+aFQs72e7ip4ysrjjb/4HxZlLwyzmy1nR7iLK6Pyvacgx/Ce5oPXnhxrV3rHp9kLLkXGuz73Ini/CsTvgu62m/cWbAw4ZjRaEjkBeo9kdHqS1XQ3b2DlpsTb0wyGRrDQvyWnijOb5j0hF25OkPdo7v3/pDJ8htekC6rk+4JBLyLs9PesNDpvy/67AD3WI/TZatemTkwYHjPaLT8ihdE5WQOdlLIbEonttjNzWXn10eLmn/U63iU0l7Z4Hr77r3nh4dtiYTgZ4JAQ6w2XjtS12SQlTFdVKR1zmrVN65umuNflf1DPxm7/wfZOAdoqvQXvQAAAABJRU5ErkJggg\u003d\u003d"
},
"description": "climbs up or down the dataLayer and repeats events that match a list of desired event keys. Optionally repeats only once and / or until a specific event is found.",
"containerContexts": [
"WEB"
]
}
___TEMPLATE_PARAMETERS___
[
{
"type": "SIMPLE_TABLE",
"name": "eventTable",
"displayName": "Repeat all occurrences of the following events",
"simpleTableColumns": [
{
"defaultValue": "",
"displayName": "Event Name",
"name": "eventName",
"type": "TEXT",
"isUnique": true,
"valueHint": "enter event name like \"view_item\""
}
],
"valueValidators": [
{
"type": "NON_EMPTY"
}
],
"alwaysInSummary": true
},
{
"type": "SELECT",
"name": "repeatCount",
"displayName": "Frequency",
"macrosInSelect": false,
"selectItems": [
{
"value": "once",
"displayValue": "Once (only first matching event)"
},
{
"value": "all",
"displayValue": "All (all matching events)"
}
],
"simpleValueType": true,
"help": "\"All\" processes every matching dataLayer event when triggered. \"Once\" repeats every matching event only for the first time it appears in the dataLayer (defined direction matters)",
"defaultValue": "all",
"alwaysInSummary": true
},
{
"type": "SELECT",
"name": "scanDirection",
"displayName": "Direction",
"macrosInSelect": false,
"selectItems": [
{
"value": "up",
"displayValue": "Up (from first to most recent event)"
},
{
"value": "down",
"displayValue": "Down (from most recent event to start)"
}
],
"simpleValueType": true,
"help": "Define if scanning for events starts at the last or first event. Note: Direction matters for \"Frequency\" and \"Stop Condition\".",
"defaultValue": "up",
"alwaysInSummary": true
},
{
"type": "SELECT",
"name": "stopCondition",
"displayName": "Stop Condition",
"macrosInSelect": false,
"selectItems": [
{
"value": "none",
"displayValue": "None"
},
{
"value": "event",
"displayValue": "Specific event"
}
],
"simpleValueType": true,
"help": "\"None\" processes a copy of all existing dataLayer events when triggered",
"defaultValue": "none",
"alwaysInSummary": true
},
{
"type": "GROUP",
"name": "stopEventSettings",
"displayName": "Stop Marker Event",
"groupStyle": "NO_ZIPPY",
"subParams": [
{
"type": "TEXT",
"name": "markerEvent",
"displayName": "Stop when this event is found",
"simpleValueType": true,
"valueValidators": [
{
"type": "NON_EMPTY"
}
]
},
{
"type": "CHECKBOX",
"name": "addConditions",
"checkboxText": "Add conditions (optonal)",
"simpleValueType": true,
"valueValidators": [
{
"type": "NON_EMPTY"
}
]
},
{
"type": "PARAM_TABLE",
"name": "additionalChecks",
"displayName": "Add one or multiple \"key equals value\" conditions (all must be met). Example: \"trackingConsent equals true\" . Key must be part of dataLayer object with specified event name.",
"paramTableColumns": [
{
"param": {
"type": "TEXT",
"name": "checkField",
"displayName": "Key Name",
"simpleValueType": true,
"help": "Enter name of a key that has to be present in the event push that is used as condition",
"valueValidators": [
{
"type": "NON_EMPTY"
}
]
},
"isUnique": true
},
{
"param": {
"type": "TEXT",
"name": "checkValue",
"displayName": "Value",
"simpleValueType": true
},
"isUnique": false
}
],
"enablingConditions": [
{
"paramName": "addConditions",
"paramValue": true,
"type": "EQUALS"
}
]
}
],
"enablingConditions": [
{
"paramName": "stopCondition",
"paramValue": "event",
"type": "EQUALS"
}
]
},
{
"type": "GROUP",
"name": "advSettings",
"displayName": "Additional settings",
"groupStyle": "ZIPPY_OPEN_ON_PARAM",
"subParams": [
{
"type": "CHECKBOX",
"name": "resetEcommerce",
"checkboxText": "Reset ecommerce object before repeating ecommerce events",
"simpleValueType": true,
"help": "Activate to add a {ecommerce: null} push before repeating objects that contain ecommerce data.",
"defaultValue": true
},
{
"type": "CHECKBOX",
"name": "resetEventId",
"checkboxText": "Reset unique event id",
"simpleValueType": true,
"help": "Delete gtm.uniqueEventId from objects before repeating. GTM will add new ids to all repeated events when active. Old ids will be added as repeater.originalEventId to all objects if this option is activated.",
"defaultValue": true
},
{
"type": "CHECKBOX",
"name": "addRepushMarker",
"checkboxText": "Add key to all repeated events",
"simpleValueType": true,
"help": "Adds a \"repeater.isRepeatedEvent\" key with value \"true\" to every handled event",
"defaultValue": false
},
{
"type": "CHECKBOX",
"name": "useRegex",
"checkboxText": "Allow Partial Match And RegEx",
"simpleValueType": true,
"help": "Check to use partial match (\"view_\" would catch \"view_item\" and \"view_item_list\" as well as \"pageview_something\") or regular expressions in your list. If not active, event names must match a list entry (case-sensitive)."
},
{
"type": "CHECKBOX",
"name": "addRandomId",
"checkboxText": "Add random id",
"simpleValueType": true,
"help": "Check this option to add a \"randomEventId\" key to every repeated event with a timestamp and a random number"
},
{
"type": "CHECKBOX",
"name": "addNameSuffix",
"checkboxText": "Add text to event name",
"simpleValueType": true,
"help": "All repeated events can optionally have a suffix added to the event name"
},
{
"type": "TEXT",
"name": "nameSuffix",
"displayName": "Event name suffix",
"simpleValueType": true,
"valueValidators": [
{
"type": "NON_EMPTY"
}
],
"defaultValue": ".repeated",
"enablingConditions": [
{
"paramName": "addNameSuffix",
"paramValue": true,
"type": "EQUALS"
}
]
}
]
}
]
___SANDBOXED_JS_FOR_WEB_TEMPLATE___
const copyFromWindow = require('copyFromWindow');
const createQueue = require('createQueue');
//const log = require('logToConsole');
const makeString = require('makeString');
const generateRandom = require("generateRandom");
const getTimestampMillis = require("getTimestampMillis");
const dataLayerPush = createQueue('dataLayer');
var currentDataLayer = copyFromWindow("dataLayer");
const mrkKey = data.markerEvent;
var processedEvents = [];
function processEvent(i) {
//returns "false" if stop condition is met
var el = currentDataLayer[i];
if (el && el.event) {
if (data.stopCondition != "none") {
//reached marker event?
if (el.event === mrkKey) {
var doBreak = true;
//conditions met?
if ((data.addConditions === true) && data.additionalChecks) {
data.additionalChecks.forEach((item) => {
doBreak = doBreak && (makeString(el[item.checkField]) == makeString(item.checkValue));
});
}
if (doBreak === true) return false;
}
}
//repeat current dataLayer event?
data.eventTable.forEach((rpekey) => {
var doThis = data.useRegex ? el.event.match(rpekey.eventName) != null : el.event === rpekey.eventName;
if ((doThis === true) && (data.repeatCount === "once") && (processedEvents.indexOf(el.event) >= 0)) doThis = false;
if (doThis === true) {
if (data.repeatCount === "once") processedEvents.push(el.event);
if (data.resetEventId === true) {
el["repeater.originalEventId"] = el["gtm.uniqueEventId"];
el["gtm.uniqueEventId"] = undefined;
}
if (data.addRandomId === true) {
el.randomEventId = getTimestampMillis() + "." + generateRandom(1000000000, 9999999999) + "." + el.event;
}
if (data.addNameSuffix === true) {
el.event = el.event + data.nameSuffix||".unique";
}
if (data.addRepushMarker === true) {
el['repeater.isRepeatedEvent'] = true;
}
if ((data.resetEcommerce === true) && el.ecommerce) {
dataLayerPush({ecommerce: null});
}
dataLayerPush(el);
}
});
}
return true;
}
if (data.scanDirection === "up") {
for (var i = 0; i < currentDataLayer.length; i++)
if (!processEvent(i)) break;
} else {
for (var i = currentDataLayer.length-1; i >=0 ; i--)
if (!processEvent(i)) break;
}
data.gtmOnSuccess();
___WEB_PERMISSIONS___
[
{
"instance": {
"key": {
"publicId": "access_globals",
"versionId": "1"
},
"param": [
{
"key": "keys",
"value": {
"type": 2,
"listItem": [
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
},
{
"type": 1,
"string": "execute"
}
],
"mapValue": [
{
"type": 1,
"string": "dataLayer"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": false
}
]
}
]
}
}
]
},
"clientAnnotations": {
"isEditedByUser": true
},
"isRequired": true
}
]
___TESTS___
scenarios: []
___NOTES___
Created on 12.11.2023, 11:42:53