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

Prevent navigation events from being tracked on tab controls #9711

Merged
merged 1 commit into from
Dec 10, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ window.GOVUK.analyticsGa4.analyticsModules =
const links = moduleElement.querySelectorAll('a')
links.forEach((link) => {
// Exclude links that serve as tab controls as they have their own event tracking
if (link.role === 'tab') {
// It would be preferable to use the role ARIA attribute to do this, but it's not present yet
// when this module is initialised because the tabs component adds the role.
// Component modules are initialised after analytics modules by GOV.UK Publishing components
if (link.classList.contains('govuk-tabs__tab')) {
return
}
const event = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('GOVUK.analyticsGa4.analyticsModules.Ga4LinkSetup', function () {
})

it('excludes links that serve as tab controls', function () {
link.role = 'tab'
link.classList.add('govuk-tabs__tab')

const Ga4LinkSetup = GOVUK.analyticsGa4.analyticsModules.Ga4LinkSetup
Ga4LinkSetup.init()
Expand Down
Loading