From e2585d62f04e2f2c8c74675288a7cb8fb005d598 Mon Sep 17 00:00:00 2001 From: Daniel Karaj Date: Wed, 6 Nov 2024 10:48:43 +0000 Subject: [PATCH 1/3] Remove section from all GA4 tracking The value of this has note been decided by PAs so should be set to `undefined` for the time being. --- .../javascripts/admin/analytics-modules/ga4-button-setup.js | 1 - .../javascripts/admin/analytics-modules/ga4-form-setup.js | 1 - .../javascripts/admin/analytics-modules/ga4-link-setup.js | 1 - .../admin/analytics-modules/ga4-visual-editor-event-handlers.js | 2 -- 4 files changed, 5 deletions(-) diff --git a/app/assets/javascripts/admin/analytics-modules/ga4-button-setup.js b/app/assets/javascripts/admin/analytics-modules/ga4-button-setup.js index 29ea2cd4ee9..8a746a8fc84 100644 --- a/app/assets/javascripts/admin/analytics-modules/ga4-button-setup.js +++ b/app/assets/javascripts/admin/analytics-modules/ga4-button-setup.js @@ -18,7 +18,6 @@ window.GOVUK.analyticsGa4.analyticsModules = event_name: 'navigation', type: 'button', text: button.textContent, - section: document.title.split(' - ')[0].replace('Error: ', ''), action: button.textContent, method: 'primary_click' } diff --git a/app/assets/javascripts/admin/analytics-modules/ga4-form-setup.js b/app/assets/javascripts/admin/analytics-modules/ga4-form-setup.js index 01eb554c5ec..67405082397 100644 --- a/app/assets/javascripts/admin/analytics-modules/ga4-form-setup.js +++ b/app/assets/javascripts/admin/analytics-modules/ga4-form-setup.js @@ -15,7 +15,6 @@ window.GOVUK.analyticsGa4.analyticsModules = ) moduleElement.dataset.ga4Form = JSON.stringify({ event_name: 'form_response', - section: document.title.split(' - ')[0].replace('Error: ', ''), action: submitButton.textContent.toLowerCase() }) }) 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 42f2fe4dd34..34f59ea044c 100644 --- a/app/assets/javascripts/admin/analytics-modules/ga4-link-setup.js +++ b/app/assets/javascripts/admin/analytics-modules/ga4-link-setup.js @@ -15,7 +15,6 @@ window.GOVUK.analyticsGa4.analyticsModules = const event = { event_name: 'navigation', type: link.role === 'button' ? 'button' : 'generic_link', - section: document.title.split(' - ')[0].replace('Error: ', ''), method: 'primary_click' } if (link.dataset.ga4Event) { diff --git a/app/assets/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.js b/app/assets/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.js index 0adb47b7771..63f64907f2f 100644 --- a/app/assets/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.js +++ b/app/assets/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.js @@ -9,7 +9,6 @@ window.GOVUK.analyticsGa4.analyticsModules = event_name: 'select_content', type: 'select', text: selectText, - section: document.title.split(' - ')[0].replace('Error: ', ''), action: selectText, tool_name: 'Visual Editor' } @@ -22,7 +21,6 @@ window.GOVUK.analyticsGa4.analyticsModules = text: buttonText, external: 'false', method: 'primary click', - section: document.title.split(' - ')[0].replace('Error: ', ''), action: 'select', tool_name: 'Visual Editor' } From ea2b165dafffd140ba1e8cd5d7d6d9a8295c2577 Mon Sep 17 00:00:00 2001 From: Daniel Karaj Date: Wed, 6 Nov 2024 10:49:47 +0000 Subject: [PATCH 2/3] Remove `action` from button tracking The value of this has note been decided by PAs so should be set to `undefined` for the time being. --- .../javascripts/admin/analytics-modules/ga4-button-setup.js | 1 - .../admin/analytics-modules/ga4-visual-editor-event-handlers.js | 2 -- 2 files changed, 3 deletions(-) diff --git a/app/assets/javascripts/admin/analytics-modules/ga4-button-setup.js b/app/assets/javascripts/admin/analytics-modules/ga4-button-setup.js index 8a746a8fc84..654a2c1c394 100644 --- a/app/assets/javascripts/admin/analytics-modules/ga4-button-setup.js +++ b/app/assets/javascripts/admin/analytics-modules/ga4-button-setup.js @@ -18,7 +18,6 @@ window.GOVUK.analyticsGa4.analyticsModules = event_name: 'navigation', type: 'button', text: button.textContent, - action: button.textContent, method: 'primary_click' } if (button.dataset.ga4Event) { diff --git a/app/assets/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.js b/app/assets/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.js index 63f64907f2f..98776294092 100644 --- a/app/assets/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.js +++ b/app/assets/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.js @@ -9,7 +9,6 @@ window.GOVUK.analyticsGa4.analyticsModules = event_name: 'select_content', type: 'select', text: selectText, - action: selectText, tool_name: 'Visual Editor' } } @@ -21,7 +20,6 @@ window.GOVUK.analyticsGa4.analyticsModules = text: buttonText, external: 'false', method: 'primary click', - action: 'select', tool_name: 'Visual Editor' } } From 11556dfc6d0bb23c8ee1d12b061176a1088621d4 Mon Sep 17 00:00:00 2001 From: Daniel Karaj Date: Wed, 6 Nov 2024 17:37:02 +0000 Subject: [PATCH 3/3] Update tracking tests Remove `section` and `action` from test cases. --- .../admin/analytics-modules/ga4-button-setup.spec.js | 8 ++++---- .../admin/analytics-modules/ga4-form-setup.spec.js | 2 +- .../admin/analytics-modules/ga4-link-setup.spec.js | 4 ++-- .../ga4-visual-editor-event-handlers.spec.js | 6 ------ 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/spec/javascripts/admin/analytics-modules/ga4-button-setup.spec.js b/spec/javascripts/admin/analytics-modules/ga4-button-setup.spec.js index fb8af06682c..089b68df76a 100644 --- a/spec/javascripts/admin/analytics-modules/ga4-button-setup.spec.js +++ b/spec/javascripts/admin/analytics-modules/ga4-button-setup.spec.js @@ -18,7 +18,7 @@ describe('GOVUK.analyticsGa4.analyticsModules', function () { ga4ButtonSetup.init() expect(button.dataset.ga4Event).toEqual( - '{"event_name":"navigation","type":"button","text":"Button","section":"Title","action":"Button","method":"primary_click"}' + '{"event_name":"navigation","type":"button","text":"Button","method":"primary_click"}' ) }) @@ -29,7 +29,7 @@ describe('GOVUK.analyticsGa4.analyticsModules', function () { ga4ButtonSetup.init() expect(button.dataset.ga4Event).toEqual( - '{"event_name":"navigation","type":"button","text":"Button","section":"Title","action":"Button","method":"primary_click"}' + '{"event_name":"navigation","type":"button","text":"Button","method":"primary_click"}' ) }) @@ -42,7 +42,7 @@ describe('GOVUK.analyticsGa4.analyticsModules', function () { ga4ButtonSetup.init() expect(button.dataset.ga4Event).toEqual( - '{"event_name":"custom_event_name","type":"button","text":"Button","section":"Title","action":"Button","method":"primary_click"}' + '{"event_name":"custom_event_name","type":"button","text":"Button","method":"primary_click"}' ) }) @@ -56,7 +56,7 @@ describe('GOVUK.analyticsGa4.analyticsModules', function () { ga4ButtonSetup.init() expect(link.dataset.ga4Event).toEqual( - '{"event_name":"navigation","type":"button","text":"Link","section":"Title","action":"Link","method":"primary_click"}' + '{"event_name":"navigation","type":"button","text":"Link","method":"primary_click"}' ) }) }) diff --git a/spec/javascripts/admin/analytics-modules/ga4-form-setup.spec.js b/spec/javascripts/admin/analytics-modules/ga4-form-setup.spec.js index ad3c00b7eaa..ca0b083fa45 100644 --- a/spec/javascripts/admin/analytics-modules/ga4-form-setup.spec.js +++ b/spec/javascripts/admin/analytics-modules/ga4-form-setup.spec.js @@ -18,7 +18,7 @@ describe('GOVUK.analyticsGa4.analyticsModules.Ga4FormSetup', function () { Ga4FormSetup.init() expect(container.dataset.ga4Form).toEqual( - '{"event_name":"form_response","section":"Title","action":"button"}' + '{"event_name":"form_response","action":"button"}' ) }) }) 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 72337dd38d7..5980855374e 100644 --- a/spec/javascripts/admin/analytics-modules/ga4-link-setup.spec.js +++ b/spec/javascripts/admin/analytics-modules/ga4-link-setup.spec.js @@ -17,7 +17,7 @@ describe('GOVUK.analyticsGa4.analyticsModules.Ga4LinkSetup', function () { Ga4LinkSetup.init() expect(link.dataset.ga4Event).toEqual( - '{"event_name":"navigation","type":"generic_link","section":"Title","method":"primary_click"}' + '{"event_name":"navigation","type":"generic_link","method":"primary_click"}' ) }) @@ -28,7 +28,7 @@ describe('GOVUK.analyticsGa4.analyticsModules.Ga4LinkSetup', function () { Ga4LinkSetup.init() expect(link.dataset.ga4Event).toEqual( - '{"event_name":"navigation","type":"button","section":"Title","method":"primary_click"}' + '{"event_name":"navigation","type":"button","method":"primary_click"}' ) }) }) diff --git a/spec/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.spec.js b/spec/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.spec.js index 155023f92e8..fef6eb4a560 100644 --- a/spec/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.spec.js +++ b/spec/javascripts/admin/analytics-modules/ga4-visual-editor-event-handlers.spec.js @@ -1,6 +1,5 @@ describe('GOVUK.analyticsGa4.analyticsModules.Ga4VisualEditorEventHandlers', function () { it('triggers ga4 tracking on visualEditorSelectChange event', function () { - document.title = 'Title - Text' const container = document.createElement('div') const select = document.createElement('select') container.setAttribute('data-module', 'ga4-visual-editor-event-handlers') @@ -28,8 +27,6 @@ describe('GOVUK.analyticsGa4.analyticsModules.Ga4VisualEditorEventHandlers', fun event_name: 'select_content', type: 'select', text: 'DROPDOWN', - section: 'Title', - action: 'DROPDOWN', tool_name: 'Visual Editor' } @@ -40,7 +37,6 @@ describe('GOVUK.analyticsGa4.analyticsModules.Ga4VisualEditorEventHandlers', fun }) it('triggers ga4 tracking on visualEditorButtonClick event', function () { - document.title = 'Title - Text' const container = document.createElement('div') const button = document.createElement('button') container.setAttribute('data-module', 'ga4-visual-editor-event-handlers') @@ -70,8 +66,6 @@ describe('GOVUK.analyticsGa4.analyticsModules.Ga4VisualEditorEventHandlers', fun text: 'BUTTON', external: 'false', method: 'primary click', - section: 'Title', - action: 'select', tool_name: 'Visual Editor' }