-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsnippet.js
81 lines (69 loc) · 2.2 KB
/
snippet.js
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
!function() {
var sitehound = window.sitehound = window.sitehound || [];
var SCRIPT_URL = ('https:' === document.location.protocol ? 'https://' : 'http://')
+ 'andyyoung.github.io/sitehound/sitehound-min.js';
if (!sitehound.sniff) {
// sitehound.js not yet loaded
if (sitehound.SNIPPET_VERSION) {
var m = 'SiteHound snippet included twice';
if (window.console && console.error) {
console.error(m);
}
sitehound.trackDebugWarn(m);
return;
}
var methods = [
'alias',
'debug',
'doNotTrack',
'identify',
'identifyOnce',
'info',
'newPage',
'ready',
'track',
'trackAndCount',
'trackLink',
'trackForm',
'trackOnce',
'trackDebugInfo',
'trackDebugWarn',
'trackError'
];
var factory = function(method) {
return function() {
var args = Array.prototype.slice.call(arguments);
args.unshift(method);
sitehound.push(args);
return sitehound;
};
};
for (var i = 0; i < methods.length; i++) {
var key = methods[i];
sitehound[key] = factory(key);
}
sitehound.sniff = function() {
sitehound.sniffOnLoad = true;
}
sitehound.SNIPPET_VERSION = '2.1';
sitehound.load = function(adaptor) {
sitehound.adaptor = adaptor;
var script = document.createElement('script');
script.type = 'text/javascript';
script.async = true;
script.src = SCRIPT_URL + '?snippet_ver=' + sitehound.SNIPPET_VERSION;
var first = document.getElementsByTagName('script')[0];
first.parentNode.insertBefore(script, first);
}
sitehound.disable = function() {
sitehound.adaptor = 'disabled';
}
}
}();
sitehound.load('segment');
// your code here
sitehound.trackPages = {
'Home': '/'
};
// call to trigger tracking after all config
sitehound.sniff();