-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.tpl
309 lines (275 loc) · 10.3 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
___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": "Quikly GTM Template",
"categories": ["ADVERTISING", "CONVERSIONS", "EMAIL_MARKETING", "MARKETING"],
"brand": {
"id": "brand_dummy",
"displayName": "",
"thumbnail": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH4AAAB+CAYAAADiI6WIAAAAAXNSR0IArs4c6QAACbxJREFUeNrtXXlTU1cUf3/pV/BL6Nf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xBzgAr6VP+KgHbA6ovw+2bgWxVj0u6xdNUBgNgEa0BNquMXB7yL21lNwhcWjCHAAAAAElFTkSuQmCC"
},
"description": "Google tag manager template that contains the Quikly snippet.",
"containerContexts": [
"WEB"
]
}
___TEMPLATE_PARAMETERS___
[
{
"type": "SELECT",
"name": "host",
"displayName": "Script Tag Host",
"selectItems": [
{
"value": "https://pixel.quikly.com/",
"displayValue": "Quikly Live"
},
{
"value": "https://pixel.quiklydemo.com/",
"displayValue": "Quikly Demo"
}
],
"simpleValueType": true,
"macrosInSelect": false,
"defaultValue": "https://pixel.quikly.com/"
},
{
"type": "TEXT",
"name": "configKey",
"displayName": "Config Key",
"simpleValueType": true,
"canBeEmptyString": false
}
]
___SANDBOXED_JS_FOR_WEB_TEMPLATE___
// Enter your template code here.
const copyFromWindow = require('copyFromWindow');
const injectScript = require('injectScript');
const log = require('logToConsole');
const queryPermission = require('queryPermission');
const setInWindow = require('setInWindow');
log('Custom Template data =', data);
const src = data.host + 'embed/js';
log('script src =', src);
const qDataPermission = queryPermission('access_globals', 'readwrite', 'qData');
const qDataLayerPermission = queryPermission('access_globals', 'readwrite', 'qDataLayer');
const quiklyPermissions = qDataPermission && qDataLayerPermission;
var qDataLayer = copyFromWindow('qDataLayer');
var qData = copyFromWindow('qData');
const onSuccess = () => {
log('Quikly embed script injected successfully');
if (quiklyPermissions) {
log('Script injected successfully');
qData = copyFromWindow('qData');
qDataLayer = copyFromWindow('qDataLayer');
} else {
log('Script does not have permission to modify qData');
data.gtmOnFailure();
}
if (qData) {
log('qData successfully assigned by Quikly script:', qData);
}
if (qDataLayer) {
log('qDataLayer successfully assigned by Quikly script:', qDataLayer);
}
if (!qData) {
log('qData was not by script, assign it now.');
qData = function() {
log('(qDataLayer ? qDataLayer : []):', (qDataLayer ? qDataLayer : []));
qDataLayer = qDataLayer ? qDataLayer : [];
qDataLayer.push(arguments);
log('Setting qDataLayer as', qDataLayer);
setInWindow('qDataLayer', qDataLayer, true);
};
if (!setInWindow('qData', qData, true)) {
log('Failed to set qData as', qData);
data.gtmOnFailure();
return;
}
}
log("Calling qData('config', 'm/" + data.configKey + "' )");
qData('config', 'm/' + data.configKey);
qData('ui', {
placements: 'auto',
platformData: {
platform: 'shopify',
// template: '{{ template.name }}',
// page: '{{ page.handle }}'
}
});
data.gtmOnSuccess();
};
const onFailure = () => {
log('Failed to inject Quikly embed script');
data.gtmOnFailure();
};
if (!qDataLayer || !qData) {
log('no qDataLayer or qData, injecting script');
injectScript(src, onSuccess, onFailure);
}
___WEB_PERMISSIONS___
[
{
"instance": {
"key": {
"publicId": "logging",
"versionId": "1"
},
"param": [
{
"key": "environments",
"value": {
"type": 1,
"string": "debug"
}
}
]
},
"clientAnnotations": {
"isEditedByUser": true
},
"isRequired": true
},
{
"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": "qData"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
}
]
},
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
},
{
"type": 1,
"string": "execute"
}
],
"mapValue": [
{
"type": 1,
"string": "qDataLayer"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
}
]
}
]
}
}
]
},
"clientAnnotations": {
"isEditedByUser": true
},
"isRequired": true
},
{
"instance": {
"key": {
"publicId": "inject_script",
"versionId": "1"
},
"param": [
{
"key": "urls",
"value": {
"type": 2,
"listItem": [
{
"type": 1,
"string": "https://pixel.quikly.com/embed/js"
},
{
"type": 1,
"string": "https://pixel.quiklydemo.com/embed/js"
}
]
}
}
]
},
"clientAnnotations": {
"isEditedByUser": true
},
"isRequired": true
}
]
___TESTS___
scenarios: []
___NOTES___
Created on 8/23/2023, 10:48:11 PM