mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-06-30 20:27:30 -04:00
Merge pull request #3273 from alphagov/fix-ga-config
Update Google Analytics tracker config
This commit is contained in:
@@ -6,10 +6,14 @@
|
||||
// Stripped-down wrapper for Google Analytics, based on:
|
||||
// https://github.com/alphagov/static/blob/master/doc/analytics.md
|
||||
const Analytics = function (config) {
|
||||
window.ga('create', config.trackingId, config.cookieDomain, config.name, { 'cookieExpires': config.expires * 24 * 60 * 60 });
|
||||
window.ga('create', {
|
||||
'trackingId': config.trackingId,
|
||||
'cookieDomain': config.cookieDomain,
|
||||
'cookieExpires': config.expires * 24 * 60 * 60
|
||||
});
|
||||
|
||||
window.ga('set', 'anonymizeIp', config.anonymizeIp);
|
||||
window.ga('set', 'displayFeaturesTask', config.displayFeaturesTask);
|
||||
window.ga('set', 'allowAdFeatures', config.allowAdFeatures);
|
||||
window.ga('set', 'transport', config.transport);
|
||||
|
||||
};
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
trackingId: trackingId,
|
||||
cookieDomain: 'auto',
|
||||
anonymizeIp: true,
|
||||
displayFeaturesTask: null,
|
||||
allowAdFeatures: false,
|
||||
transport: 'beacon',
|
||||
name: 'GOVUK.analytics',
|
||||
expires: 365
|
||||
});
|
||||
|
||||
|
||||
@@ -29,9 +29,8 @@ describe("Analytics", () => {
|
||||
trackingId: 'UA-75215134-1',
|
||||
cookieDomain: 'auto',
|
||||
anonymizeIp: true,
|
||||
displayFeaturesTask: null,
|
||||
allowAdFeatures: false,
|
||||
transport: 'beacon',
|
||||
name: 'GOVUK.analytics',
|
||||
expires: 365
|
||||
});
|
||||
|
||||
@@ -49,9 +48,9 @@ describe("Analytics", () => {
|
||||
|
||||
setUpArguments = window.ga.mock.calls;
|
||||
|
||||
expect(setUpArguments[0]).toEqual(['create', 'UA-75215134-1', 'auto', 'GOVUK.analytics', { 'cookieExpires': 31536000 }]);
|
||||
expect(setUpArguments[0]).toEqual(['create', { 'trackingId': 'UA-75215134-1', 'cookieDomain': 'auto', 'cookieExpires': 31536000 }]);
|
||||
expect(setUpArguments[1]).toEqual(['set', 'anonymizeIp', true]);
|
||||
expect(setUpArguments[2]).toEqual(['set', 'displayFeaturesTask', null]);
|
||||
expect(setUpArguments[2]).toEqual(['set', 'allowAdFeatures', false]);
|
||||
expect(setUpArguments[3]).toEqual(['set', 'transport', 'beacon']);
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user