-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate.tpl
349 lines (318 loc) · 9.29 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
___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": "Microsoft Clarity - Official",
"categories": ["ANALYTICS", "HEAT_MAP", "SESSION_RECORDING"],
"brand": {
"id": "Microsoft",
"displayName": "Microsoft",
"thumbnail": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACABAMAAAAxEHz4AAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAElBMVEUAAADyUCJ/ugAApO//uQD///8951e2AAAAAXRSTlMAQObYZgAAAAFiS0dEBfhv6ccAAAAHdElNRQfkCgUWITsZUDiiAAAAS0lEQVRo3u3MQQ3AIAAEsMuCAGZhCkiwgH9NOLj3Hq2A5q1m8nxVBAKBQCAQCAQCgUAgEPSAP9jVSsapBAKBQCAQCAQCgUAgEPTgAruK0CdlWNSzAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDIwLTEwLTA1VDIyOjMzOjU5KzAwOjAwPT1n8QAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyMC0xMC0wNVQyMjozMzo1OSswMDowMExg300AAAAASUVORK5CYII\u003d"
},
"description": "Clarity is a user behavior analytics tool, which helps you understand how users are interacting with your website. Supported features include:\nSession Recordings\nHeatmaps\nML Insights",
"containerContexts": [
"WEB"
]
}
___TEMPLATE_PARAMETERS___
[
{
"type": "TEXT",
"name": "projectId",
"displayName": "Clarity Project Id",
"simpleValueType": true,
"help": "Copy your clarity project Id here. You can find it in the project Url from the browser. Example: https://clarity.microsoft.com/projects/view/\"projectId\"/",
"valueValidators": [
{
"type": "NON_EMPTY",
"errorMessage": "You must provide a clarity project Id"
},
{
"type": "REGEX",
"args": [
"[0-9a-z]+"
],
"errorMessage": "Incorrect project Id. You can find it in the project Url from the browser. Example: https://clarity.microsoft.com/projects/view/\"projectId\"/"
}
]
},
{
"type": "GROUP",
"name": "advanced",
"displayName": "Custom Options",
"groupStyle": "ZIPPY_CLOSED",
"subParams": [
{
"type": "GROUP",
"name": "custom_id",
"displayName": "Custom Identifiers",
"groupStyle": "NO_ZIPPY",
"subParams": [
{
"type": "TEXT",
"name": "userId",
"displayName": "Custom Id",
"simpleValueType": true,
"help": "Custom id such as an email, can help you view the user journey across browsers and devices",
"valueHint": "[email protected]"
},
{
"type": "TEXT",
"name": "sessionId",
"displayName": "Session Id",
"simpleValueType": true,
"help": "Custom session id to help you filter for this session later",
"enablingConditions": [
{
"paramName": "userId",
"paramValue": "",
"type": "PRESENT"
}
],
"valueHint": "custom-session-id"
},
{
"type": "TEXT",
"name": "pageId",
"displayName": "Page Id",
"simpleValueType": true,
"help": "Custom page id to help you filter for this page later",
"enablingConditions": [
{
"paramName": "userId",
"paramValue": "",
"type": "PRESENT"
}
],
"valueHint": "custom-page-id"
},
{
"type": "TEXT",
"name": "friendlyName",
"displayName": "Friendly Name",
"simpleValueType": true,
"help": "Friendly name for the user",
"enablingConditions": [
{
"paramName": "userId",
"paramValue": "",
"type": "PRESENT"
}
],
"valueHint": "Mona"
}
],
"help": "Custom Identifiers are informational data values about site visitors",
"enablingConditions": []
},
{
"type": "SIMPLE_TABLE",
"name": "custom_tag",
"displayName": "Custom Tag",
"simpleTableColumns": [
{
"defaultValue": "",
"displayName": "Key",
"name": "key",
"type": "TEXT",
"valueHint": ""
},
{
"defaultValue": "",
"displayName": "Value",
"name": "value",
"type": "TEXT",
"valueValidators": [
{
"type": "STRING_LENGTH",
"args": [
1,
255
]
}
],
"valueHint": ""
}
],
"help": "Custom tags are customizable filters that allow you to analyze recordings and heatmaps in different directions",
"valueValidators": []
}
]
}
]
___SANDBOXED_JS_FOR_WEB_TEMPLATE___
// Require the necessary APIs
const injectScript = require('injectScript');
const queryPermission = require('queryPermission');
const createArgumentsQueue = require('createArgumentsQueue');
const encodeUri = require('encodeUri');
//const log = require('logToConsole');
// Create clarity const
const clarity = createArgumentsQueue('clarity', 'clarity.q');
const customTags = data.custom_tag || [];
const friendlyName = data.friendlyName || '';
const sessionId = data.sessionId || '';
const pageId = data.pageId || '';
// Reconstruct customer clarity script URL
const url = "https://www.clarity.ms/tag/"+encodeUri(data.projectId)+"?ref=gtm";
// Handle Success
const onCustomerSuccess = () => {
data.gtmOnSuccess();
};
// Handle Failure
const onCustomerFailure = () => {
data.gtmOnFailure();
};
// If the URL input by the user matches the permissions set for the template,
// inject the script with the onSuccess and onFailure methods as callbacks.
if (queryPermission('inject_script', "https://www.clarity.ms")) {
for(var i=0; i < customTags.length; i++){
clarity('set', customTags[i].key, customTags[i].value);
}
if(data.userId){
clarity("identify", data.userId, sessionId, pageId, friendlyName);
}
injectScript(url, onCustomerSuccess, onCustomerFailure);
} else {
data.gtmOnFailure();
}
___WEB_PERMISSIONS___
[
{
"instance": {
"key": {
"publicId": "inject_script",
"versionId": "1"
},
"param": [
{
"key": "urls",
"value": {
"type": 2,
"listItem": [
{
"type": 1,
"string": "https://www.clarity.ms/*"
}
]
}
}
]
},
"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": "clarity"
},
{
"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": "clarity.q"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
}
]
}
]
}
}
]
},
"clientAnnotations": {
"isEditedByUser": true
},
"isRequired": true
}
]
___TESTS___
scenarios: []
___NOTES___
Created on 2/2/2021, 12:41:15 PM