Skip to content

Commit

Permalink
Linting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
andysellick committed Oct 28, 2020
1 parent 7a6adde commit 7a51f94
Showing 1 changed file with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
var analyticsInit = function(gaProperty, gaPropertyCrossDomain, linkedDomains) {
"use strict";
var analyticsInit = function (gaProperty, gaPropertyCrossDomain, linkedDomains) {
'use strict'

var consentCookie = window.GOVUK.getConsentCookie();
var consentCookie = window.GOVUK.getConsentCookie()

var dummyAnalytics = {
addLinkedTrackerDomain: function(){},
setDimension: function(){},
setOptionsForNextPageView: function(){},
trackEvent: function(){},
trackPageview: function(){},
trackShare: function(){},
};
addLinkedTrackerDomain: function () {},
setDimension: function () {},
setOptionsForNextPageView: function () {},
trackEvent: function () {},
trackPageview: function () {},
trackShare: function () {}
}

// Disable analytics by default
// This will be reversed below, if the consent cookie says usage cookies are allowed
var disabler = 'ga-disable-' + gaProperty
window[disabler] = true;
window[disabler] = true

if (consentCookie && consentCookie["usage"]) {
window[disabler] = false;
if (consentCookie && consentCookie.usage) {
window[disabler] = false

// Load Google Analytics libraries
GOVUK.StaticAnalytics.load();
window.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 cookieDomain = (document.domain === 'www.gov.uk') ? '.www.gov.uk' : document.domain

// Configure profiles, setup custom vars, track initial pageview
var analytics = new GOVUK.StaticAnalytics({
var analytics = new window.GOVUK.StaticAnalytics({
universalId: gaProperty,
cookieDomain: cookieDomain,
allowLinker: true
});
})

// Make interface public for virtual pageviews and events
GOVUK.analytics = analytics;
window.GOVUK.analytics = analytics

if (linkedDomains && linkedDomains.length > 0) {
GOVUK.analytics.addLinkedTrackerDomain(gaPropertyCrossDomain, 'govuk', linkedDomains);
window.GOVUK.analytics.addLinkedTrackerDomain(gaPropertyCrossDomain, 'govuk', linkedDomains)
}
} else {
GOVUK.analytics = dummyAnalytics
window.GOVUK.analytics = dummyAnalytics
}
}

Expand Down

0 comments on commit 7a51f94

Please sign in to comment.