From 5162640abf24f7ec14c85f8d5feaa186190a6b24 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Fri, 30 Aug 2019 18:39:44 +0100 Subject: [PATCH] Now calling cross domain linker once - have added a test, which appears to produce the result we want - now calling the linker code once, but with multiple domains --- app/assets/javascripts/analytics/init.js.erb | 2 +- .../analytics_toolkit/analytics.spec.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/analytics/init.js.erb b/app/assets/javascripts/analytics/init.js.erb index 8ddcf73af..e83162761 100644 --- a/app/assets/javascripts/analytics/init.js.erb +++ b/app/assets/javascripts/analytics/init.js.erb @@ -40,7 +40,7 @@ // Make interface public for virtual pageviews and events GOVUK.analytics = analytics; - GOVUK.analytics.addLinkedTrackerDomain(secondaryId, 'govuk', 'design-system.service.gov.uk'); + GOVUK.analytics.addLinkedTrackerDomain(secondaryId, 'govuk', 'design-system.service.gov.uk, passport.service.gov.uk, apply-for-eu-settled-status.homeoffice.gov.uk'); } else { GOVUK.analytics = dummyAnalytics } diff --git a/spec/javascripts/analytics_toolkit/analytics.spec.js b/spec/javascripts/analytics_toolkit/analytics.spec.js index 511d7fead..1a98e6b69 100644 --- a/spec/javascripts/analytics_toolkit/analytics.spec.js +++ b/spec/javascripts/analytics_toolkit/analytics.spec.js @@ -399,5 +399,19 @@ describe('GOVUK.Analytics', function () { expect(allArgs).toContain(['test.set', 'displayFeaturesTask', null]) expect(allArgs).toContain(['test.send', 'pageview']) }) + + it('adds multiple linked domains to universal analytics', function () { + analytics.addLinkedTrackerDomain('1234', 'test', 'www.example.com, www.something.com') + + var allArgs = window.ga.calls.allArgs() + expect(allArgs).toContain(['create', '1234', 'auto', {'name': 'test'}]) + expect(allArgs).toContain(['require', 'linker']) + expect(allArgs).toContain(['test.require', 'linker']) + expect(allArgs).toContain(['linker:autoLink', ['www.example.com, www.something.com']]) + expect(allArgs).toContain(['test.linker:autoLink', ['www.example.com, www.something.com']]) + expect(allArgs).toContain(['test.set', 'anonymizeIp', true]) + expect(allArgs).toContain(['test.set', 'displayFeaturesTask', null]) + expect(allArgs).toContain(['test.send', 'pageview']) + }) }) })