mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 19:03:30 -05:00
Removes the following fields from the tracker config: - `name`, which was erroring due to it including a `.` - `displayFeaturesTask` which seems to be deprecated Also refactors the `create` command to put all fields into the options parameter, as shown in the developer docs: https://developers.google.com/analytics/devguides/collection/analyticsjs/creating-trackers
41 lines
956 B
JavaScript
41 lines
956 B
JavaScript
(function (window) {
|
|
"use strict";
|
|
|
|
window.GOVUK = window.GOVUK || {};
|
|
|
|
const trackingId = 'UA-75215134-1';
|
|
|
|
// Disable analytics by default
|
|
window[`ga-disable-${trackingId}`] = true;
|
|
|
|
const initAnalytics = function () {
|
|
|
|
// guard against being called more than once
|
|
if (!('analytics' in window.GOVUK)) {
|
|
|
|
window[`ga-disable-${trackingId}`] = false;
|
|
|
|
// Load Google Analytics libraries
|
|
window.GOVUK.Analytics.load();
|
|
|
|
// Configure profiles and make interface public
|
|
// for custom dimensions, virtual pageviews and events
|
|
window.GOVUK.analytics = new GOVUK.Analytics({
|
|
trackingId: trackingId,
|
|
cookieDomain: 'auto',
|
|
anonymizeIp: true,
|
|
allowAdFeatures: false,
|
|
transport: 'beacon',
|
|
expires: 365
|
|
});
|
|
|
|
// Track initial pageview
|
|
window.GOVUK.analytics.trackPageview();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
window.GOVUK.initAnalytics = initAnalytics;
|
|
})(window);
|