Google Analytics

Google Analytics dashboard

If you want to access our Google Analytics dashboard, ask the CCS Head of Digital Analytics.

The Javascript code for our analytics, cookie banner and cookie settings page is held in the digitalmarketplace-govuk-frontend repo. Any changes should be made there, released to npm, and pulled into the FE apps.

Analytics opt-in

Digital Marketplace requires users to opt-in to Google Analytics, via a banner displayed at the top of each page.

If a user clicks ‘Yes’ or ‘No’ to state their preference, a dm_cookies_policy cookie is set with ‘analytics’ set to either True or False. Setting a preference hides the cookie banner for the user on subsequent pages.

See the Cookie Banner component README for full details of the Cookie Banner functionality.

The user can change their cookie preferences on the cookie settings page (linked to via their account). The cookie banner is not shown on this page, to avoid having two forms doing the same thing.

If a user opts in to analytics, the Google Analytics cookies are initialised, and a page view event is triggered. The dm_cookies_policy cookie is updated with their preference set to True.

If a user opts out of analytics, any existing Google Analytics cookies are deleted. The dm_cookies_policy cookie is updated with their preference set to False.

See the Cookie Settings component README for full details of the Cookie Settings page functionality.

Cross domain tracking

Our frontend apps have cross domain tracking enabled, to allow GOV.UK to measure page views originating from the Digital Marketplace. For example, if a buyer clicks on a link on our app to the guidance published on GOV.UK, a _ga parameter will be appended to the URL and get picked up by GOV.UK’s analytics setup.

The cross domain tracking is initialised as part of the digitalmarketplace-govuk-frontend repo analytics code.

Stripping PII

To avoid sending personally identifiable information (PII) to Google Analytics, we strip any values that match an email regex before firing the page view event. None of our views intentionally include PII in the URL, but this could happen accidentally.

For example, if a user’s browser auto-filled one of the search boxes with their email address, that value would appear in the address bar as /search?q=myemail%40example.com. However the analytics tracking code would mask that value, sending the page view as /search?q=[email].