Skip to main content
Warning This document has not been updated for a while now. It may be out of date.
Last updated: 11 Jan 2021

static: Analytics

The analytics code for GOV.UK (including the documentation) has now been migrated to govuk_publishing_components and is now pulled into static from there.

Adding domains to GOV.UK's cross domain linker

Once a service starts sending analytics data to the shared GA property and has configured their system to include in their cross domain linking, we must also configure to include their domain in our cross linker configuration.

Add the domain of the service to the linkedDomains var in analytics.js.erb.

Only the domain should be added, GA will ignore any path details e.g. /government/service/

Note that GA matches subdomains of any domains added this way. So also includes

On that basis the simplest course of action would appear to be to simply add or even and then it'll just match everything we want it to. We must not do this for very good reasons:

  • any link from to a matching domain would have a URL parameter automatically added to it e.g. This could interfere with that site's own analytics.
  • the client ID might be reset.

Once the changes to the linker configuration have been deployed a performance analyst will need to check that everything is working correctly. Since static PRs can take upwards of half an hour to pass CI tests, it's worth having a revert PR ready early on just in case.