-
Notifications
You must be signed in to change notification settings - Fork 3
/
gov_search_sp_script.js
43 lines (42 loc) · 1.64 KB
/
gov_search_sp_script.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
// <!-- Snowplow starts plowing - Search vE.2.14.0 -->
;(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","https://www2.gov.bc.ca/StaticWebResources/static/sp/sp-2-14-0.js","snowplow"));
var collector = 'spm.apps.gov.bc.ca';
window.snowplow('newTracker','rt',collector, {
appId: "Snowplow_gov",
cookieLifetime: 86400 * 548,
platform: 'web',
post: true,
forceSecureTracker: true,
contexts: {
webPage: true,
performanceTiming: true
}
});
window.snowplow('enableActivityTracking', 30, 30); // Ping every 30 seconds after 30 seconds
window.snowplow('enableLinkClickTracking');
window.snowplow('trackPageView',null,
[{
schema: 'iglu:ca.bc.gov/meta_data/jsonschema/1-0-0',
data: {
node_id: document.querySelector("meta[name='current_page_id']").getAttribute("content")
}
}]
);
if (window.location.search.indexOf('q=') > -1) {
window.snowplow('trackSiteSearch',
getUrlParamArray('q','')
);
}
function getUrlParamArray(param, defaultValue) {
var vars = [];
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
if ( key === param ) {
vars.push(value);
}
});
return vars;
}
// <!-- Snowplow stops plowing -->