Skip to content

Commit

Permalink
Add discovery_engine_attribution_token to GA4 pageview
Browse files Browse the repository at this point in the history
  • Loading branch information
andysellick committed Mar 25, 2024
1 parent d41506c commit 80a75fd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,8 @@
of the commit log.

## Unreleased

* Add discovery_engine_attribution_token to GA4 pageview ([PR #3951](https://github.com/alphagov/govuk_publishing_components/pull/3951))
* Remove support for specialist topics from contextual navigation ie breadcrumbs ([#3927](https://github.com/alphagov/govuk_publishing_components/pull/3927))
* Improve test coverage of contextual breadcrumb logic ([PR #3944](https://github.com/alphagov/govuk_publishing_components/pull/3944) and [PR #3945](https://github.com/alphagov/govuk_publishing_components/pull/3945))
* Remove GA4 callout tracking from the govspeak component ([PR #3946](https://github.com/alphagov/govuk_publishing_components/pull/3946))
Expand Down
Expand Up @@ -62,7 +62,8 @@ window.GOVUK.analyticsGa4.analyticsModules = window.GOVUK.analyticsGa4.analytics
intervention: this.getBannerPresence('[data-ga4-intervention-banner]'),
query_string: this.getQueryString(),
search_term: this.getSearchTerm(),
spelling_suggestion: this.getMetaContent('spelling-suggestion')
spelling_suggestion: this.getMetaContent('spelling-suggestion'),
discovery_engine_attribution_token: this.getMetaContent('discovery-engine-attribution-token')
}
}
window.GOVUK.analyticsGa4.core.sendData(data)
Expand Down
Expand Up @@ -60,7 +60,8 @@ describe('Google Tag Manager page view tracking', function () {
intervention: undefined,
query_string: undefined,
search_term: undefined,
spelling_suggestion: undefined
spelling_suggestion: undefined,
discovery_engine_attribution_token: undefined
}
}
spyOn(GOVUK.analyticsGa4.core, 'getTimestamp').and.returnValue('123456')
Expand Down Expand Up @@ -644,4 +645,11 @@ describe('Google Tag Manager page view tracking', function () {
GOVUK.analyticsGa4.analyticsModules.PageViewTracker.init()
expect(window.dataLayer[0]).toEqual(expected)
})

it('correctly sets the discovery_engine_attribution_token parameter', function () {
createMetaTags('discovery-engine-attribution-token', 'searchyMcSearch')
expected.page_view.discovery_engine_attribution_token = 'searchyMcSearch'
GOVUK.analyticsGa4.analyticsModules.PageViewTracker.init()
expect(window.dataLayer[0]).toEqual(expected)
})
})

0 comments on commit 80a75fd

Please sign in to comment.