-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
341 lines (305 loc) · 12.3 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<link rel="manifest" href="/web-sdk-test/manifest.json">
<script type="text/javascript">
var clevertap = { event: [], profile: [], account: [], region: 'sk1-staging-12' };
// var clevertap = { event: [], profile: [], account: [], region: 'eu1' };
// clevertap.account.push({ id: "ZWW-WWW-WWRZ" }); // eu1 BR App
clevertap.account.push({ id: "WR5-Z98-W56Z" }); // QA Champs
// clevertap.account.push({ id: "485-7W7-495Z" }); // Shilpa account
//clevertap.account.push({ id: "R99-655-K75Z" });
(function() {
var wzrk = document.createElement("script");
wzrk.type = "text/javascript";
wzrk.async = true;
//wzrk.src = "a.js";
//wzrk.src = "web_personalization_new_sdk";
// wzrk.src = "https://cdn.jsdelivr.net/gh/CleverTap/clevertap-web-sdk@task/SDK-2454/carousel_height_fix/clevertap.js";
// wzrk.src = 'https://cdn.jsdelivr.net/gh/CleverTap/clevertap-web-sdk@task/SDK-2041/web_inbox/clevertap.js';
// wzrk.src = 'https://cdn.jsdelivr.net/gh/CleverTap/clevertap-web-sdk@task/SDK-2678/frequency_caps/clevertap.js';
wzrk.src = 'https://d2r1yp2w7bby2u.cloudfront.net/js/clevertap.min.js';
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(wzrk, s);
})();
</script>
</head>
<body>
<script type="text/javascript">
document.addEventListener("CT_web_personalization", function(event) {
const data = event.detail;
const topic = data.kv.topic;
switch (topic) {
case "Cart drop-off": {
renderCartDropOffPersonalisationCampaign(data)
break;
}
}
});
function renderCartDropOffPersonalisationCampaign (data) {
const name = data.kv.Name;
const product = data.kv.Cart;
// Add your custom rendering logic here
// raise notification viewed event
clevertap.renderNotificationViewed(data);
clevertap.renderNotificationClicked(data);
/**
* You may want to track click on the entire popup that you just rendered or on a button within it.
* To do so, you’ll have to add below line within the click listeners of the popup/button
* `clevertap.renderNotificationClicked(data);`
* Ex: If you had a button with id shopNow and are using jQuery, you’d simply have to do
* $(‘#shopNow’).click(() => { clevertap.renderNotificationClicked(data); })
*/
}
function pushprofile() {
var id = makeid(5);
clevertap.profile.push({
Site: {
Name: "User " + id, // User's name
Email: id + "@clevertap.com", // User's email
Phone: "+917710004770", // User's phone with country code
Gender: "aasd", // Can be either M or F
Employed: "Y", // Can be either Y or N
Education: "Graduate", // Can be either School, College or Graduate
Married: "Y", // Can be either Y or N
DOB: $WZRK_WR.setDate(20150501), // Set date in format yyyymmdd
Language: "Deutsche",
"MSG-email": true, // Disable email notifications
"MSG-push": true, // Enable push notifications
"MSG-sms": true // Enable sms notifications
}
});
console.log("pushprofile successful");
}
function pushbid() {
clevertap.event.push("Place Bid");
console.log("place bid");
}
function pushcharged() {
clevertap.event.push("Charged", {
"Product name": "Casio Chronograph Watch",
ts: new Date()
});
console.log("push charged");
}
function pushProductSearched() {
clevertap.event.push("Product Searched");
console.log("push Product Searched");
}
function pushEventAddToCart() {
clevertap.event.push("Added to Cart", {
"Product ID": "pr_57235721c9f9a1",
"product name": "Lamb Curry Cut1",
Price: 298,
Long_1: 6473329386,
Long_2: 2,
Currency: "INR"
});
}
function clearLocalStorage() {
localStorage.clear();
}
function makeid(length) {
var text = "";
var possible =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < length; i++)
text += possible.charAt(
Math.floor(Math.random() * possible.length)
);
return text;
}
function logout() {
clevertap.logout();
}
function onClickOUL() {
clevertap.onUserLogin.push({
Site: {
Email: `qw${Math.ceil(
Math.random() * 10002312
)}@gmail.com`
// Email: "[email protected]"
}
});
getLS();
}
function onClickOULSame() {
let value = document.getElementById("constantOUL").value;
clevertap.onUserLogin.push({
Site: {
// Email: `${Math.ceil(Math.random() * 100012)}@gmail.com`
Email: `${value}@gmail.com`
}
});
getLS();
}
function onClickOULIdentitySame() {
let value = document.getElementById("constantOULIdentity").value;
clevertap.onUserLogin.push({
Site: {
// Email: `${Math.ceil(Math.random() * 100012)}@gmail.com`
Identity: `${value}`
}
});
getLS();
}
function onClickPP() {
clevertap.profile.push({
Site: {
Email: `as${Math.ceil(
Math.random() * 10002320
)}@gmail.com`
}
});
getLS();
}
function onClickPPSame() {
let value = document.getElementById("constantPP").value;
clevertap.profile.push({
Site: {
Email: `${value}@gmail.com`
}
});
}
function onClickPPIdentitySame() {
let value = document.getElementById("constantPPIdentity").value;
clevertap.profile.push({
Site: {
Identity: `${value}`
}
});
}
function onClickEP() {
clevertap.event.push("Product Eaten");
clevertap.event.push("Message Received");
clevertap.event.push("Message Viewed");
clevertap.event.push("Product add to cart");
getLS();
}
function pushSelectedEvents() {
var adc = document.getElementById("adc").checked;
var ps = document.getElementById("ps").checked;
var pv = document.getElementById("pv").checked;
if (!adc && !ps && !pv) {
alert("Select atleast one event");
return;
}
if (adc) clevertap.event.push("Added to Cart");
if (ps) clevertap.event.push("Product Sold");
if (pv) clevertap.event.push("Product Viewed");
document.getElementById("adc").checked = false;
document.getElementById("ps").checked = false;
document.getElementById("pv").checked = false;
getLS();
}
function enablePush() {
clevertap.notifications.push({
"titleText": 'Wish to receive push notifications?',
"bodyText": 'Click Yes to receive push notifications',
"okButtonText": 'Yes',
"rejectButtonText": 'No',
"serviceWorkerPath": '/web-sdk-test/js/clevertap_sw.js'});
}
function getLS() {
var LRU_CACHE = decodeURIComponent(localStorage["WZRK_X"]);
var WZRK_K = decodeURIComponent(localStorage["WZRK_K"]);
var WZRK_G = decodeURIComponent(localStorage["WZRK_G"]);
var WZRK_EV = decodeURIComponent(localStorage["WZRK_EV"]);
var WZRK_ARP = decodeURIComponent(localStorage["WZRK_ARP"]);
var data = `<div>WZRK_K: ${WZRK_K}</div><br /><div>WZRK_G: ${WZRK_G}</div><br /><div>LRU_CAHCE: ${LRU_CACHE}</div><br /><div>WZRK_EV: ${WZRK_EV}</div><br /><div>WZRK_ARP: ${WZRK_ARP}</div>`;
document.getElementById("lsData").innerHTML = data;
}
function clearLS() {
localStorage.clear();
getLS();
}
function getProfile() {
var customerType = clevertap.profile.getAttribute("Customer type");
console.log(customerType);
}
</script>
<link rel="stylesheet" href="/web-sdk-test/style.css" />
<!-- <br />
<button type="button" onclick="pushprofile()">Profile Push!</button>
<br />
<button type="button" onclick="pushProductSearched()">
Product Searched
</button>
<br />
<button type="button" onclick="pushEventAddToCart()">
Add to Cart!
</button>
<br />
<button type="button" onclick="pushcharged()">Charged!</button>
<br />
<button type="button" onclick="pushbid()">Bid!</button>
<br />
<button type="button" onclick="logout()">Deprecated -> Logout</button>
<br />
<button type="button" onclick="clearLocalStorage()">
Clear Local Storage
</button> -->
<h1>Test A-JS</h1>
<button onclick="onClickPP()">Random PP</button>
<button onclick="onClickOUL()">Random OUL</button>
<button onclick="onClickEP()">Event Push</button>
<hr />
<br />
<p>On User Login</p>
<input type="text" id="constantOUL" class="textInput" /><input
type="text"
disabled
value="@gmail.com"
class="textInput"
/>
<button onclick="onClickOULSame()" class="inputBtn">OUL</button>
<br />
<hr />
<br />
<hr />
<p>Profile Push</p>
<input type="text" id="constantPP" class="textInput" /><input
type="text"
disabled
value="@gmail.com"
class="textInput"
/>
<button onclick="onClickPPSame()" class="inputBtn">PP</button>
<hr />
<br />
<hr />
<input type="checkbox" name="event" value="adc" id="adc" /> Added to
Cart <br />
<input type="checkbox" name="event" value="ps" id="ps" /> Product Sold
<br />
<input type="checkbox" name="event" value="pv" id="pv" /> Product Viewed
<br />
<button id="eventPushSelect" onclick="pushSelectedEvents()">
Push Selected Events
</button>
<button id="enablePushNotifications" onclick="enablePush()">
Enable Push Notifications
</button>
<br />
<hr />
<button
onclick="getLS()"
style="background: #2b39ff;color: white; padding: 5px"
>
Show Local Storage
</button>
<br /><br />
<button
onclick="clearLS()"
style="background: red;color: white; padding: 5px"
>
Clear Local Storage
</button>
<br>
<br />
<br />
<br />
<hr />
<div id="lsData"></div>
</body>
</html>