-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_old.html
203 lines (185 loc) · 10.4 KB
/
index_old.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
<html>
<head>
<title>My title</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="index.css">
<script>
!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).tracardi=t()}(function(){return function n(o,i,a){function c(e,t){if(!i[e]){if(!o[e]){var r="function"==typeof require&&require;if(!t&&r)return r(e,!0);if(d)return d(e,!0);throw(r=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",r}r=i[e]={exports:{}},o[e][0].call(r.exports,function(t){return c(o[e][1][t]||t)},r,r.exports,n,o,i,a)}return i[e].exports}for(var d="function"==typeof require&&require,t=0;t<a.length;t++)c(a[t]);return c}({1:[function(t,e,r){"use strict";!function(t){t=t||window;var r=[],n=!1,o=!1;function i(){if(!n){n=!0;for(var t=0;t<r.length;t++)r[t].fn.call(window,r[t].ctx);r=[]}}function a(){"complete"===document.readyState&&i()}t.documentReady=function(t,e){if("function"!=typeof t)throw new TypeError("callback for documentReady(fn) must be a function");n?setTimeout(function(){t(e)},1):(r.push({fn:t,ctx:e}),"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(t){"function"==typeof t&&n.push(t)},call:function(e){n.forEach(function(t){t(e)})}},function(){for(var r=[],n="liliput.min.js",t=["track"],e=0;e<t.length;e++){var o=t[e];window.tracker[o]=function(e){return function(){var t=Array.prototype.slice.call(arguments);return t.unshift(e),r.push(t),window.tracker}}(o)}function i(){if(console.debug("[Tracker] 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 t=r.shift(),e=t.shift();tracker[e]&&tracker[e].apply(tracker,t)}else console.error("[Tracardi] Callbacks stopped. Tracker not initialized.");else console.error("[Tracardi] Callbacks stopped. Tracker not initialized. Is script url correct?")}documentReady(function(){var t,e,r;"1"!==navigator.doNotTrack||!0!==(null===(t=options)||void 0===t||null===(e=t.tracker)||void 0===e||null===(r=e.settings)||void 0===r?void 0:r.respectDoNotTrack)?((e=document.createElement("script")).type="text/javascript",e.async=!0,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("//")?e.src=options.tracker.url.script+"/"+n:e.src=options.tracker.url.script:e.src=n,console.debug("[Tracker] Loading: "+e.src),e.addEventListener?e.addEventListener("load",function(t){i()},!1):e.onreadystatechange=function(){"complete"!==this.readyState&&"loaded"!==this.readyState||i(window.event)},(r=document.getElementsByTagName("script")[0]).parentNode.insertBefore(e,r)):console.error("[Tracker] 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)});
const options = {
listeners: {
onTracardiReady: ({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", {"page": "hello"});
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)
}
});
},
onSessionSet: () => {},
onConsentRequired: () => {
const consentBox = document.getElementById('consentBox');
if (consentBox) {
consentBox.style.display = "block";
}
}
},
tracker: {
url: {
script: 'dist/liliput.min.js',
api: 'http://localhost:8686'
},
// external: [
// // {url: 'https://api.ipify.org?format=json', storage: "__tr_l", key: "location"},
// {url: 'https://geolocation-db.com/json/', storage: "__tr_lap"}
// ],
source: {
id: "test-source"
},
profile: {
id: "test"
},
context: {
performance: true,
location: true,
// location: {
// url: 'https://ipapi.co/json/', data: function (data) {
// if (!data) {
// return null
// }
// return {
// country: {
// name: data.country_name,
// code: data.country_code,
// },
// city: data.city,
// county: data.region,
// latitude: data.latitude,
// longitude: data.longitude,
// ip: data.IPv4
// }
// }
// }
},
settings: {
respectDoNotTrack: false,
trackExternalLinks: ['tracardi.com']
}
}
}
//# sourceMappingURL=loader.min.js.map
</script>
<script>
window.response.context.profile = true;
window.tracker.track("page-view", {"product": "Sun glasses - Badoo", "price": 13.45}, {
"test": 1,
"context": {"sdsd": {"asas": [1, 2, 3]}}
})
// window.tracker.track("profile-interest", {"Vacation": 1})
// window.tracker.track("page-view", {"basket": 1});
// window.tracker.track("personal-data", {
// "name": Math.random(),
// "surname": "Doe",
// "email": "[email protected]",
// "location": "Berlin/Germany"
// });
</script>
<style>
</style>
</head>
<body>
<h1>
<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>
<h2>Events</h2>
<section>
<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>
<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</BUTTON>
</div>
<pre id="response-to-custom-event" style="display: none"></pre>
</section>
<h3>External link</h3>
<a href="https://tracardi.com" style="color: white">External link</a>
</body>
</html>