forked from snowplow/snowplow-javascript-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathintegration-template.html
More file actions
92 lines (76 loc) · 2.21 KB
/
Copy pathintegration-template.html
File metadata and controls
92 lines (76 loc) · 2.21 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
<!DOCTYPE html>
<html>
<head>
<title>Integration test page</title>
</head>
<body>
<p id="title">Page for sending requests to request_recorder</p>
<script>
document.body.className += ' loaded';
</script>
<script>
;(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","./snowplow.js","snowplow"));
// Taken from a random environment variable
var subdomain = '<%= subdomain %>';
window.snowplow('newTracker', 'cf', subdomain + '.ngrok.io', {
encodeBase64: true,
appId: 'CFe23a',
platform: 'mob',
contexts: {
webPage: true
}
});
window.snowplow('setUserId', 'Malcolm');
window.snowplow('trackPageView', 'My Title', [ // Auto-set page title; add page context
{
schema: "iglu:com.example_company/user/jsonschema/2-0-0",
data: {
userType: 'tester'
}
}
]);
// This should have different pageViewId in web_page context
window.snowplow('trackPageView');
window.snowplow('trackStructEvent', 'Mixes', 'Play', 'MRC/fabric-0503-mix', '', '0.0');
window.snowplow('trackUnstructEvent', {
schema: 'iglu:com.acme_company/viewed_product/jsonschema/5-0-0',
data: {
productId: 'ASO01043'
}
}, [], { type: 'ttm', value: 1477401868 });
var orderId = 'order-123';
window.snowplow('addTrans',
orderId,
'acme',
'8000',
'100',
'50',
'phoenix',
'arizona',
'USA',
'JPY'
);
// addItem might be called for each item in the shopping cart,
// or not at all.
window.snowplow('addItem',
orderId,
'1001',
'Blue t-shirt',
'clothing',
'2000',
'2',
'JPY'
);
// trackTrans sends the transaction to Snowplow tracking servers.
// Must be called last to commit the transaction.
window.snowplow('trackTrans');
// track unhandled exception
window.snowplow("enableErrorTracking");
function raiseException() { notExistentObject.notExistentProperty(); }
setTimeout(raiseException, 2500);
</script>
</body>
</html>