diff --git a/app/assets/javascripts/analytics/init.js.erb b/app/assets/javascripts/analytics/init.js.erb index ffeb5921d..06378a9b1 100644 --- a/app/assets/javascripts/analytics/init.js.erb +++ b/app/assets/javascripts/analytics/init.js.erb @@ -27,6 +27,7 @@ var cookieDomain = (document.domain == 'www.gov.uk') ? '.www.gov.uk' : document.domain; var universalId = '<%= Rails.application.config.ga_universal_id %>'; + var secondaryId = '<%= Rails.application.config.ga_secondary_id %>'; // Configure profiles, setup custom vars, track initial pageview var analytics = new GOVUK.StaticAnalytics({ @@ -39,6 +40,8 @@ // Make interface public for virtual pageviews and events GOVUK.analytics = analytics; + GOVUK.analytics.addLinkedTrackerDomain(secondaryId, 'www.gov.uk', 'gov.uk'); + GOVUK.analytics.addLinkedTrackerDomain(secondaryId, 'designsystem', 'design-system.service.gov.uk'); } else { GOVUK.analytics = dummyAnalytics } diff --git a/config/application.rb b/config/application.rb index 3fa9886d4..1614872c7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -54,5 +54,6 @@ class Application < Rails::Application # Google Analytics ID config.ga_universal_id = ENV.fetch("GA_UNIVERSAL_ID", "UA-UNSET") + config.ga_secondary_id = ENV.fetch("GA_SECONDARY_ID", "UA-UNSET") end end diff --git a/config/environments/production.rb b/config/environments/production.rb index ded642019..32fe5bd7f 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -69,4 +69,5 @@ config.eager_load = true config.ga_universal_id = ENV.fetch("GA_UNIVERSAL_ID", "UA-26179049-1") + config.ga_secondary_id = ENV.fetch("GA_SECONDARY_ID", "UA-145652997-1") end