forked from snowplow/snowplow-javascript-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcookieless.html
More file actions
137 lines (121 loc) · 4.14 KB
/
Copy pathcookieless.html
File metadata and controls
137 lines (121 loc) · 4.14 KB
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
<!DOCTYPE html>
<!--
! Copyright (c) 2012-2013 Snowplow Analytics Ltd. All rights reserved.
!
! This program is licensed to you under the Apache License Version 2.0,
! and you may not use this file except in compliance with the Apache License Version 2.0.
! You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
!
! Unless required by applicable law or agreed to in writing,
! software distributed under the Apache License Version 2.0 is distributed on an
! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
-->
<html>
<head>
<title>Cookieless tracking example for snowplow.js</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Snowplow starts plowing -->
<script type="text/javascript">
;(function(p, l, o, w, i, n, g) {
if (!p[i]) {
p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || []
p.GlobalSnowplowNamespace.push(i)
p[i] = function() {
;(p[i].q = p[i].q || []).push(arguments)
}
p[i].q = p[i].q || []
n = l.createElement(o)
g = l.getElementsByTagName(o)[0]
n.async = 1
n.src = w
g.parentNode.insertBefore(n, g)
}
})(window, document, 'script', '../sp.js', 'snowplow')
window.snowplow('newTracker', 'cf', '127.0.0.1:9090', {
// Initialise a tracker
anonymousTracking: true,
encodeBase64: false, // Default is true
appId: 'CFe23a', // Site ID can be anything you want. Set it if you're tracking more than one site in this account
platform: 'mob',
contexts: {
webPage: true,
gaCookies: true,
performanceTiming: true
}
})
</script>
<!-- Snowplow stops plowing -->
</head>
<body>
<header>
<h1>Cookieless_tracking_examples_for_snowplow.js</h1>
<p>
Warning: if your browser's Do Not Track feature is enabled and
respectDoNotTrack is enabled, all tracking will be prevented.
</p>
<p>
If you are viewing the page using a file URL, you must edit the script
URL in the Snowplow tag to include an http scheme. Otherwise a file
scheme will be inferred and the page will attempt to load sp.js from the
local filesystem..
</p>
</header>
<nav>
<div id="login-form" style="display:block">
<span class="fontawesome-user"></span>
<input type="text" id="user" placeholder="Username" />
<span class="fontawesome-lock"></span>
<input type="password" id="pass" placeholder="Password" />
<input type="submit" value="Login" onclick="login()" />
</div>
</nav>
<section>
<div id="logout-form" style="display:none">
<button type="button" onclick="logout()">Logout</button>
</div>
</section>
<section>
<button type="button" onclick="playMix()">Play a Mix</button>
</section>
<script>
function playMix() {
alert('Playing a DJ mix')
window.snowplow(
'trackStructEvent',
'Mixes',
'Play',
'MRC/fabric-0503-mix',
'',
'0.0'
)
}
function login() {
window.snowplow('enableUserTracking', 'localStorage')
window.snowplow('setUserId', 'alex 123') // Business-defined user ID
window.snowplow('setUserIdFromLocation', 'id') // To test this, reload the page with ?id=xxx
window.snowplow('setUserIdFromCookie', '_sp_id.4209') // Test this using Firefox because Chrome doesn't allow local cookies.
window.snowplow('setCustomUrl', '/overridden-url/') // Override the page URL
window.snowplow('enableActivityTracking', 10, 10) // Ping every 10 seconds after 10 seconds
toggle()
return false
}
function logout() {
window.snowplow('disableUserTracking', 'localStorage')
toggle()
return false
}
function toggle() {
var login = document.getElementById('login-form')
var logout = document.getElementById('logout-form')
if (login.style.display == 'block') {
login.style.display = 'none'
logout.style.display = 'block'
} else {
login.style.display = 'block'
logout.style.display = 'none'
}
}
</script>
</body>
</html>