-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinit.js.erb
30 lines (24 loc) · 962 Bytes
/
init.js.erb
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
(function(global) {
"use strict";
// Load Google Analytics libraries
GOVUK.StaticAnalytics.load();
// Use document.domain in dev, preview and staging so that tracking works
// Otherwise explicitly set the domain as www.gov.uk (and not gov.uk).
var cookieDomain = (document.domain == 'www.gov.uk') ? '.www.gov.uk' : document.domain;
var universalId = 'UA-26179049-1';
// Configure profiles, setup custom vars, track initial pageview
var analytics = new GOVUK.StaticAnalytics({
universalId: universalId,
cookieDomain: cookieDomain,
allowLinker: true,
// This is served by Fastly in production, and returns an empty 200 response
govukTrackerGifUrl: '<%= asset_path "/static/a" %>',
});
// Make interface public for virtual pageviews and events
GOVUK.analytics = analytics;
if (global.ga) {
var ga = global.ga;
ga('require', 'linker');
ga('linker:autoLink', ['planforbritain.gov.uk']);
}
})(window);