-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignal.html
291 lines (266 loc) · 15.4 KB
/
signal.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
<!DOCTYPE html>
<html>
<head>
<title>My title</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<meta name="topics" content="topic1,topic2">
<link rel="stylesheet" href="index.css">
<!-- <script>-->
<!-- !function (e) {-->
<!-- "object" == typeof exports && "undefined" != typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define([], e) : ("undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this).tracardi = e()-->
<!-- }(function () {-->
<!-- return function n(o, i, a) {-->
<!-- function c(t, e) {-->
<!-- if (!i[t]) {-->
<!-- if (!o[t]) {-->
<!-- var r = "function" == typeof require && require;-->
<!-- if (!e && r) return r(t, !0);-->
<!-- if (d) return d(t, !0);-->
<!-- throw(r = new Error("Cannot find module '" + t + "'")).code = "MODULE_NOT_FOUND", r-->
<!-- }-->
<!-- r = i[t] = {exports: {}}, o[t][0].call(r.exports, function (e) {-->
<!-- return c(o[t][1][e] || e)-->
<!-- }, r, r.exports, n, o, i, a)-->
<!-- }-->
<!-- return i[t].exports-->
<!-- }-->
<!-- for (var d = "function" == typeof require && require, e = 0; e < a.length; e++) c(a[e]);-->
<!-- return c-->
<!-- }({-->
<!-- 1: [function (e, t, r) {-->
<!-- "use strict";-->
<!-- !function (e) {-->
<!-- e = e || window;-->
<!-- var r = [], n = !1, o = !1;-->
<!-- function i() {-->
<!-- if (!n) {-->
<!-- n = !0;-->
<!-- for (var e = 0; e < r.length; e++) r[e].fn.call(window, r[e].ctx);-->
<!-- r = []-->
<!-- }-->
<!-- }-->
<!-- function a() {-->
<!-- "complete" === document.readyState && i()-->
<!-- }-->
<!-- e.documentReady = function (e, t) {-->
<!-- if ("function" != typeof e) throw new TypeError("callback for documentReady(fn) must be a function");-->
<!-- n ? setTimeout(function () {-->
<!-- e(t)-->
<!-- }, 1) : (r.push({-->
<!-- fn: e,-->
<!-- ctx: t-->
<!-- }), "complete" === document.readyState || !document.attachEvent && "interactive" === document.readyState ? setTimeout(i, 1) : o || (document.addEventListener ? (document.addEventListener("DOMContentLoaded", i, !1), window.addEventListener("load", i, !1)) : (document.attachEvent("onreadystatechange", a), window.attachEvent("onload", i)), o = !0))-->
<!-- }-->
<!-- }(window);-->
<!-- var n = [];-->
<!-- window.tracker || (window.tracker = {}), window.response || (window.response = {context: {}}), window.onTracardiReady = {-->
<!-- bind: function (e) {-->
<!-- "function" == typeof e && n.push(e)-->
<!-- }, call: function (t) {-->
<!-- n.forEach(function (e) {-->
<!-- e(t)-->
<!-- })-->
<!-- }-->
<!-- }, function () {-->
<!-- for (var r = [], n = "liliput.min.js", e = ["track"], t = 0; t < e.length; t++) {-->
<!-- var o = e[t];-->
<!-- window.tracker[o] = function (t) {-->
<!-- return function () {-->
<!-- var e = Array.prototype.slice.call(arguments);-->
<!-- return e.unshift(t), r.push(e), window.tracker-->
<!-- }-->
<!-- }(o)-->
<!-- }-->
<!-- function i() {-->
<!-- if (console.debug("[Loader] Rerun callbacks."), void 0 !== window.tracardi.default) if (window.tracardi.default.getState().plugins.tracardi.initialized) for (window.tracker = window.tracardi.default; 0 < r.length;) {-->
<!-- var e = r.shift(), t = e.shift();-->
<!-- tracker[t] && tracker[t].apply(tracker, e)-->
<!-- } else console.error("[Loader] Callbacks stopped. Tracker not initialized."); else console.error("[Loader] Callbacks stopped. Tracker not initialized. Is script url correct?")-->
<!-- }-->
<!-- documentReady(function () {-->
<!-- var e, t, r;-->
<!-- "1" !== navigator.doNotTrack || !0 !== (null === (e = options) || void 0 === e || null === (t = e.tracker) || void 0 === t || null === (r = t.settings) || void 0 === r ? void 0 : r.respectDoNotTrack) ? ((t = document.createElement("script")).type = "text/javascript", t.async = !0, options.context = {-->
<!-- gpu: function () {-->
<!-- var e, t, r = document.createElement("canvas"), n = null;-->
<!-- try {-->
<!-- if (e = r.getContext("webgl", {powerPreference: "high-performance"}) || r.getContext("experimental-webgl", {powerPreference: "high-performance"})) {-->
<!-- var o = e.getExtension("WEBGL_debug_renderer_info");-->
<!-- if (o) return t = e.getParameter(o.UNMASKED_VENDOR_WEBGL), n = navigator.userAgent.includes("Firefox") ? e.getParameter(e.RENDERER) : e.getParameter(o.UNMASKED_RENDERER_WEBGL), {-->
<!-- vendor: {-->
<!-- id: o.UNMASKED_VENDOR_WEBGL,-->
<!-- name: t-->
<!-- }, renderer: {id: o.UNMASKED_RENDERER_WEBGL, renderer: n}-->
<!-- }-->
<!-- }-->
<!-- } catch (e) {-->
<!-- }-->
<!-- return null-->
<!-- }()-->
<!-- }, void 0 !== options.tracker || void 0 !== options.tracker.url || void 0 !== options.tracker.url.script ? (null !== options.tracker.url.script ? options.tracker.url.script.startsWith("http") || options.tracker.url.script.startsWith("//") ? t.src = options.tracker.url.script + "/" + n : t.src = options.tracker.url.script : t.src = n, console.debug("[Loader] Loading: " + t.src), t.addEventListener ? t.addEventListener("load", function (e) {-->
<!-- i()-->
<!-- }, !1) : t.onreadystatechange = function () {-->
<!-- "complete" !== this.readyState && "loaded" !== this.readyState || i(window.event)-->
<!-- }, (r = document.getElementsByTagName("script")[0]).parentNode.insertBefore(t, r)) : console.error("[Loader] Undefined options.tracker.url.script. This url defines location of tracker code.")) : console.log("We are respecting do not track setting. Tracardi disabled.")-->
<!-- })-->
<!-- }()-->
<!-- }, {}]-->
<!-- }, {}, [1])(1)-->
<!-- });-->
<!-- //# sourceMappingURL=loader.min.js.map-->
<!-- const options = {-->
<!-- tracker: {-->
<!-- url: {-->
<!-- script: 'dist/liliput.min.js',-->
<!-- api: 'http://localhost:8686'-->
<!-- },-->
<!-- source: {-->
<!-- id: "demo-website"-->
<!-- },-->
<!-- settings: {-->
<!-- trackExternalLinks: ['example.com', 'tracardi.com']-->
<!-- },-->
<!-- context: {-->
<!-- "cookies": true,-->
<!-- "storage": true,-->
<!-- "screen": true,-->
<!-- "page": true,-->
<!-- "browser": true,-->
<!-- "performance": true,-->
<!-- "location": true-->
<!-- },-->
<!-- auto: {-->
<!-- events: [-->
<!-- ["increase-interest", {"interest": "laptops", "value": 1}],-->
<!-- ["increase-interest", {"interest": "systems", "value": 2}],-->
<!-- ["page-view", {"category": "laptops"}]-->
<!-- ],-->
<!-- triggers: [-->
<!-- {tag: "product", trigger: 'onVisible', data: {event: 'image-viewed'}},-->
<!-- {tag: "title", trigger: 'onTextSelect', data: {event: 'text-selected'}}-->
<!-- ]-->
<!-- },-->
<!-- // external: [-->
<!-- // {url: 'https://api.ipify.org?format=json', storage: "__tr_1", key: "location1"},-->
<!-- // {url: 'https://api.myip.com/', storage: "__tr_2", key: "location2"}-->
<!-- // ],-->
<!-- }-->
<!-- }-->
<!-- window.onTracardiReady.bind(({helpers, context}) => {-->
<!-- document.getElementById('response').innerText = JSON.stringify(context, null, " ");-->
<!-- const btn0 = document.querySelector('#page-view-event')-->
<!-- btn0.style.backgroundColor = "red";-->
<!-- btn0.style.color = "white";-->
<!-- helpers.addListener(btn0, 'mouseover', async () => {-->
<!-- try {-->
<!-- const response = await helpers.track("page-view-mouse-over", {"page": "hello"}, {asBeacon: true});-->
<!-- if (response) {-->
<!-- const responseToCustomEvent = document.getElementById('response-to-custom-event');-->
<!-- responseToCustomEvent.innerText = JSON.stringify(response.data, null, " ");-->
<!-- responseToCustomEvent.style.display = "block"-->
<!-- }-->
<!-- } catch (e) {-->
<!-- alert(e)-->
<!-- }-->
<!-- });-->
<!-- })-->
<!-- </script>-->
<!-- <script>-->
<!-- window.tracker.track("profile-interest", {"Vacation": 1})-->
<!-- </script>-->
<script src="dist/signal.min.js" id="tracardi-signal" data-signal-api="http://localhost:8686/track" data-signal-token="locust-test">
</script>
</head>
<body>
<h1 data-tracardi-tag="title">
<BOLD>TRACARDI</BOLD>
<THIN>JavaScript Integration Test Page</THIN>
</h1>
<section>
<p>This page load TRACARDI Javascript to show case how it can be utilized to collect user data.</p>
</section>
<pre style="display: none">
const options = {
tracker: {
url: {
script: 'http://localhost:8686/tracker',
api: 'http://localhost:8686'
},
source: {
id: "7303142e-c0e1-45a4-8b1b-6e2f0381b141"
}
}
}
</pre>
<button id="context">Test context bind</button>
<button onClick="testClick()">Test on click</button>
<a href="https://example.com/test">External patched link</a>
<a href="https://abc.com">NOT External patched link</a>
<h2>Events</h2>
<section data-tracardi-tag="over">
<p>This is the example code that sends events to TRACARDI. Events pinpoint what happened on your web-site</p>
<pre>
window.response.context.profile = true;
window.tracker.track("purchase-order", {"product": "Sun glasses - Badoo", "price": 13.45})
window.tracker.track("interest", {"Vacation": 1})
window.tracker.track("page-view", {"basket": 1});
</pre>
</section>
<h2>TRACARDI response</h2>
<section>
<p>TRACARDI will respond with information on user profile, session, and information on what was saved in the
system.</p>
<p>This information can be used to change your page on the fly with javascript.</p>
<pre id="response"></pre>
</section>
<div class="wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex">
<div class="wp-block-button is-style-cubebtndark fr-animate fr-move-up fr-delay-5"><a class="wp-block-button__link has-textonprimary-color has-primary-background-color has-text-color has-background wp-element-button" href="https://tracardi.com/index.php/contact-us/" style="border-radius:3px;padding-top:15px;padding-right:40px;padding-bottom:15px;padding-left:40px">Contact Us!!!</a></div>
<style scoped>.is-style-cubebtndark .wp-block-button__link{border:none !important;box-shadow: 0px 2px 4px rgb(45 35 66 / 20%), 0px 7px 13px -3px rgb(45 35 66 / 30%), inset 0px -3px 0px rgb(58 65 111 / 50%);
text-shadow: 0 1px 0 rgb(0 0 0 / 40%);}.is-style-cubebtndark .wp-block-button__link:hover{transform: translateY(-2px);}.is-style-cubebtndark .wp-block-button__link:active{transform: translateY(2px);box-shadow: 0px 2px 2px rgb(45 35 66 / 15%)}</style>
</div>
<h2>TRACARDI listeners</h2>
<h3>onConsentRequired</h3>
<section>
<p>TRACARDI can listen to the data that comes from the system and can react to it. For example if you did not
consent to data processing it can popup a message and ask for consent.</p>
<p>This is an example of code that shows white box below if consent is required.</p>
<pre>
const options = {
listeners: {
onConsentRequired: () => {
const consentBox = document.getElementById('consentBox');
if (consentBox) {
consentBox.style.display = "block";
}
}
}
}
</pre>
<p>It is shown because TRACARDI returned that this information source requires user consent. See response from
TRACARDI above.</p>
<p>Once you click one of the buttons it will never appear again. </p>
<div id="consentBox" class="consent">
<div class="consent-content">
We are using cookies to collect anonymous data.
<button id="consent-all">Allow all</button>
<button id="block-all">Black all</button>
</div>
</div>
</section>
<h3>onContextReady</h3>
<section>
<p>You can listen and react when the page is rady and TRACARDI returns user context information.
Than you can bind new tracking to any given element on page or change the page depending on the data tracardi
returned.
</p>
<p>Click on button below to sent new event to TRACARDI. </p>
<div>
<BUTTON id="custom-click-event">NEW EVENT</BUTTON>
<BUTTON id="page-view-event">PAGE-VIEW EVENT ONMOUSEOVER</BUTTON>
</div>
<pre id="response-to-custom-event" style="display: none"></pre>
</section>
<img src="https://tracardi.com/wp-content/uploads/2021/12/tracardi-icon-2-150x150.png" width="100" alt="Tracardi logo"
height="100" data-tracardi-tag="product"/>
</body>
</html>