-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is to make the structure of tracking modules more consistent
- Loading branch information
Showing
3 changed files
with
22 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,14 +66,14 @@ describe('Google Tag Manager page view tracking', function () { | |
} | ||
|
||
it('returns a standard page view', function () { | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a page view with a specific status code', function () { | ||
window.httpStatusCode = 404 | ||
expected.page_view.status_code = '404' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
|
@@ -112,7 +112,7 @@ describe('Google Tag Manager page view tracking', function () { | |
expected.page_view[tag.gtmName] = tag.value | ||
} | ||
|
||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
|
@@ -156,7 +156,7 @@ describe('Google Tag Manager page view tracking', function () { | |
expected.page_view[tag.gtmName] = tag.value | ||
} | ||
|
||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
|
@@ -177,99 +177,99 @@ describe('Google Tag Manager page view tracking', function () { | |
content.setAttribute('lang', 'wakandan') | ||
expected.page_view.language = 'wakandan' | ||
|
||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('set incorrectly', function () { | ||
expected.page_view.language = nullValue | ||
|
||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
}) | ||
|
||
it('returns a pageview without a language', function () { | ||
expected.page_view.language = nullValue | ||
|
||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a pageview with history', function () { | ||
createMetaTags('content-has-history', 'true') | ||
expected.page_view.history = 'true' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a pageview without history', function () { | ||
createMetaTags('content-has-history', 'banana') | ||
expected.page_view.history = 'false' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a pageview on a withdrawn page', function () { | ||
createMetaTags('withdrawn', 'withdrawn') | ||
expected.page_view.withdrawn = 'true' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a pageview on a page with a first published date', function () { | ||
createMetaTags('first-published-at', '2022-03-28T19:11:00.000+00:00') | ||
expected.page_view.first_published_at = '2022-03-28' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a pageview on a page with a last updated date', function () { | ||
createMetaTags('updated-at', '2021-03-28T19:11:00.000+00:00') | ||
expected.page_view.updated_at = '2021-03-28' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a pageview on a page with a last public updated date', function () { | ||
createMetaTags('public-updated-at', '2020-03-28T19:11:00.000+00:00') | ||
expected.page_view.public_updated_at = '2020-03-28' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a pageview on a page marked with a publishing government', function () { | ||
createMetaTags('publishing-government', 'labour') | ||
expected.page_view.publishing_government = 'labour' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a pageview on a page marked with a political status', function () { | ||
createMetaTags('political-status', 'ongoing') | ||
expected.page_view.political_status = 'ongoing' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a pageview on a page marked with a primary publishing organisation', function () { | ||
createMetaTags('primary-publishing-organisation', 'Home Office') | ||
expected.page_view.primary_publishing_organisation = 'Home Office' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a pageview on a page marked with ids for contributing organisations', function () { | ||
createMetaTags('analytics:organisations', 'some organisations') | ||
expected.page_view.organisations = 'some organisations' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
it('returns a pageview on a page marked with world locations', function () { | ||
createMetaTags('analytics:world-locations', 'some world locations') | ||
expected.page_view.world_locations = 'some world locations' | ||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
expect(window.dataLayer[0]).toEqual(expected) | ||
}) | ||
|
||
|
@@ -294,7 +294,7 @@ describe('Google Tag Manager page view tracking', function () { | |
linkForURLMock.href = '#[email protected]' | ||
linkForURLMock.click() | ||
|
||
GOVUK.Gtm.sendPageView() | ||
GOVUK.analyticsGA4.pageViewTracker.sendPageView() | ||
|
||
// Reset the page location for other tests | ||
linkForURLMock.href = '#' | ||
|