-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.tpl
218 lines (192 loc) · 5.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
___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": "Booster Box - UTMs Storing",
"categories": ["AFFILIATE_MARKETING", "ADVERTISING"],
"brand": {
"id": "booster_box",
"displayName": "BoosterBox"
},
"description": "This Custom Template is created to helps you store UTMs values in the Local Storage of the browser and use them as you wish. Made by Simone Dal Pino for Booster Box.",
"containerContexts": [
"WEB"
]
}
___TEMPLATE_PARAMETERS___
[
{
"type": "TEXT",
"name": "Source",
"displayName": "Source",
"simpleValueType": true
},
{
"type": "TEXT",
"name": "Medium",
"displayName": "Medium",
"simpleValueType": true
},
{
"type": "TEXT",
"name": "Campaign",
"displayName": "Campaign",
"simpleValueType": true
}
]
___SANDBOXED_JS_FOR_WEB_TEMPLATE___
//Invoke the localStorage
const localStorage = require('localStorage');
//Assign the value of UI fields
const source = data.Source;
const medium = data.Medium;
const campaign = data.Campaign;
//Set the values in the localStorage (this keys must be first validated in the permission section)
localStorage.setItem('source', source);
localStorage.setItem('medium', medium);
localStorage.setItem('campaign', campaign);
data.gtmOnSuccess();
___WEB_PERMISSIONS___
[
{
"instance": {
"key": {
"publicId": "access_local_storage",
"versionId": "1"
},
"param": [
{
"key": "keys",
"value": {
"type": 2,
"listItem": [
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
}
],
"mapValue": [
{
"type": 1,
"string": "source"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
}
]
},
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
}
],
"mapValue": [
{
"type": 1,
"string": "medium"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
}
]
},
{
"type": 3,
"mapKey": [
{
"type": 1,
"string": "key"
},
{
"type": 1,
"string": "read"
},
{
"type": 1,
"string": "write"
}
],
"mapValue": [
{
"type": 1,
"string": "campaign"
},
{
"type": 8,
"boolean": true
},
{
"type": 8,
"boolean": true
}
]
}
]
}
}
]
},
"clientAnnotations": {
"isEditedByUser": true
},
"isRequired": true
}
]
___TESTS___
scenarios:
- name: Test1
code: "// Enter your template code here.\n\nconst wind = require('localStorage');\n\
//Problema on Data Object\nvar input = data.array;\n\nlet i = 0;\nconst source\
\ = data.Source;\nconst medium = data.Medium;\nconst campaign = data.Campaign;\n\
\nwhile (i <= data.length) {\n if(i==0){wind.setItem('source', source); wind.console.log(source.toString);}\n\
\ if(i==1){wind.setItem('source', medium);}\n if(i==2){wind.setItem('source',\
\ campaign);}\n \n}\n"
- name: Test2
code: "// Enter your template code here.\n\nconst localStorage = require('localStorage');\n\
//Problema on Data Object\nvar input = data.array;\nconst source = data.Source;\n\
const medium = data.Medium;\nconst campaign = data.Campaign;\nif (data.use_array)\
\ {\n \n for (var i = 0; i < data.list.length; i++) {\n if(i==0){localStorage.setItem('source',\
\ source); localStorage.console.log(source.toString);}\n if(i==1){localStorage.setItem('source',\
\ medium);}\n if(i==2){localStorage.setItem('source', campaign);}\n }\n}\n\n\
\n"
___NOTES___
Created on 25/1/2023, 17:41:42