diff --git a/app/assets/javascripts/admin/analytics-modules/ga4-link-setup.js b/app/assets/javascripts/admin/analytics-modules/ga4-link-setup.js index aa663904dd5..5c6923c2c24 100644 --- a/app/assets/javascripts/admin/analytics-modules/ga4-link-setup.js +++ b/app/assets/javascripts/admin/analytics-modules/ga4-link-setup.js @@ -16,10 +16,10 @@ window.GOVUK.analyticsGa4.analyticsModules = event_name: 'navigation', type: link.role === 'button' ? 'button' : 'generic_link' } - if (link.dataset.ga4Event) { - Object.assign(event, JSON.parse(link.dataset.ga4Event)) + if (link.dataset.ga4Link) { + Object.assign(event, JSON.parse(link.dataset.ga4Link)) } - link.dataset.ga4Event = JSON.stringify(event) + link.dataset.ga4Link = JSON.stringify(event) }) }) } diff --git a/spec/javascripts/admin/analytics-modules/ga4-link-setup.spec.js b/spec/javascripts/admin/analytics-modules/ga4-link-setup.spec.js index 0b393661625..10fd0377777 100644 --- a/spec/javascripts/admin/analytics-modules/ga4-link-setup.spec.js +++ b/spec/javascripts/admin/analytics-modules/ga4-link-setup.spec.js @@ -16,7 +16,7 @@ describe('GOVUK.analyticsGa4.analyticsModules.Ga4LinkSetup', function () { const Ga4LinkSetup = GOVUK.analyticsGa4.analyticsModules.Ga4LinkSetup Ga4LinkSetup.init() - expect(link.dataset.ga4Event).toEqual( + expect(link.dataset.ga4Link).toEqual( '{"event_name":"navigation","type":"generic_link"}' ) }) @@ -27,7 +27,7 @@ describe('GOVUK.analyticsGa4.analyticsModules.Ga4LinkSetup', function () { const Ga4LinkSetup = GOVUK.analyticsGa4.analyticsModules.Ga4LinkSetup Ga4LinkSetup.init() - expect(link.dataset.ga4Event).toEqual( + expect(link.dataset.ga4Link).toEqual( '{"event_name":"navigation","type":"button"}' ) })