Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add discovery_engine_attribution_token to GA4 pageview #3951

Merged
merged 1 commit into from Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
})
})