From 16c6af2c167c25779094ce472e7a35a198d9a45d Mon Sep 17 00:00:00 2001
From: AshGDS <8880610+AshGDS@users.noreply.github.com>
Date: Fri, 28 Jun 2024 12:11:16 +0100
Subject: [PATCH 1/7] Remove set-ga-client-id-on-form
---
.../modules/set-ga-client-id-on-form.js | 22 -------------------
.../service_sign_in/_choose_sign_in.html.erb | 2 +-
.../set-ga-client-id-on-form.spec.js | 19 ----------------
.../service_sign_in/choose_sign_in_test.rb | 2 +-
4 files changed, 2 insertions(+), 43 deletions(-)
delete mode 100644 app/assets/javascripts/modules/set-ga-client-id-on-form.js
delete mode 100644 spec/javascripts/set-ga-client-id-on-form.spec.js
diff --git a/app/assets/javascripts/modules/set-ga-client-id-on-form.js b/app/assets/javascripts/modules/set-ga-client-id-on-form.js
deleted file mode 100644
index 7c15f4d4e..000000000
--- a/app/assets/javascripts/modules/set-ga-client-id-on-form.js
+++ /dev/null
@@ -1,22 +0,0 @@
-window.GOVUK = window.GOVUK || {}
-window.GOVUK.Modules = window.GOVUK.Modules || {};
-
-(function (Modules) {
- function SetGaClientIdOnForm ($module) {
- this.$module = $module
- }
-
- SetGaClientIdOnForm.prototype.init = function () {
- var form = this.$module
-
- if (window.ga) {
- window.ga(function (tracker) {
- var clientId = tracker.get('clientId')
- var action = form.getAttribute('action')
- form.setAttribute('action', action + '?_ga=' + clientId)
- })
- }
- }
-
- Modules.SetGaClientIdOnForm = SetGaClientIdOnForm
-})(window.GOVUK.Modules)
diff --git a/app/views/content_items/service_sign_in/_choose_sign_in.html.erb b/app/views/content_items/service_sign_in/_choose_sign_in.html.erb
index b4148c85c..3ea02d8c6 100644
--- a/app/views/content_items/service_sign_in/_choose_sign_in.html.erb
+++ b/app/views/content_items/service_sign_in/_choose_sign_in.html.erb
@@ -14,7 +14,7 @@
<% end %>
<%
- data_attrs = { module: "track-radio-group set-ga-client-id-on-form" }
+ data_attrs = { module: "track-radio-group" }
data_attrs["tracking-code"] = @content_item.tracking_code if @content_item.tracking_code
data_attrs["tracking-domain"] = @content_item.tracking_domain if @content_item.tracking_domain
data_attrs["tracking-name"] = @content_item.tracking_name if @content_item.tracking_name
diff --git a/spec/javascripts/set-ga-client-id-on-form.spec.js b/spec/javascripts/set-ga-client-id-on-form.spec.js
deleted file mode 100644
index 69272fefa..000000000
--- a/spec/javascripts/set-ga-client-id-on-form.spec.js
+++ /dev/null
@@ -1,19 +0,0 @@
-var $ = window.jQuery
-
-describe('SetGaClientIdOnForm', function () {
- var GOVUK = window.GOVUK
- var mockTracker = { clientId: 'clientId' }
- mockTracker.get = function (arg) { return this[arg] }
- window.ga = function (callback) { callback(mockTracker) }
- var form
-
- beforeEach(function () {
- form = $('
')
- var setId = new GOVUK.Modules.SetGaClientIdOnForm(form[0])
- setId.init()
- })
-
- it('sets the _ga client id as a query param on the form action', function () {
- expect(form.attr('action')).toBe('/endpoint?_ga=clientId')
- })
-})
diff --git a/test/integration/service_sign_in/choose_sign_in_test.rb b/test/integration/service_sign_in/choose_sign_in_test.rb
index d92a3563a..f1bacd78c 100644
--- a/test/integration/service_sign_in/choose_sign_in_test.rb
+++ b/test/integration/service_sign_in/choose_sign_in_test.rb
@@ -20,7 +20,7 @@ class ChooseSignInTest < ActionDispatch::IntegrationTest
assert_not page.has_css?("#proposition-menu")
assert page.has_css?('.gem-c-back-link[href="/log-in-file-self-assessment-tax-return"]', text: "Back")
- assert page.has_css?('form[data-module="track-radio-group set-ga-client-id-on-form"]')
+ assert page.has_css?('form[data-module="track-radio-group"]')
assert page.has_css?("form[data-tracking-code='UA-xxxxxx']")
assert page.has_css?("form[data-tracking-domain='tax.service.gov.uk']")
assert page.has_css?("form[data-tracking-name='somethingClicky']")
From c0ad177bbd8020f649cd0dd28a8f2cc91b5a5e40 Mon Sep 17 00:00:00 2001
From: AshGDS <8880610+AshGDS@users.noreply.github.com>
Date: Fri, 28 Jun 2024 12:13:33 +0100
Subject: [PATCH 2/7] Remove track-radio-group.js
---
.../javascripts/modules/track-radio-group.js | 69 ---------------
.../service_sign_in/_choose_sign_in.html.erb | 9 +-
spec/javascripts/track-radio-group.spec.js | 87 -------------------
.../service_sign_in/choose_sign_in_test.rb | 4 -
4 files changed, 1 insertion(+), 168 deletions(-)
delete mode 100644 app/assets/javascripts/modules/track-radio-group.js
delete mode 100644 spec/javascripts/track-radio-group.spec.js
diff --git a/app/assets/javascripts/modules/track-radio-group.js b/app/assets/javascripts/modules/track-radio-group.js
deleted file mode 100644
index 4543df4f9..000000000
--- a/app/assets/javascripts/modules/track-radio-group.js
+++ /dev/null
@@ -1,69 +0,0 @@
-window.GOVUK = window.GOVUK || {}
-window.GOVUK.Modules = window.GOVUK.Modules || {};
-
-(function (Modules) {
- function TrackRadioGroup (element) {
- this.element = element
- }
-
- TrackRadioGroup.prototype.init = function () {
- this.track(this.element)
-
- if (this.crossDomainTrackingEnabled(this.element)) {
- this.addCrossDomainTracking(this.element)
- }
- }
-
- TrackRadioGroup.prototype.track = function (element) {
- this.element.addEventListener('submit', function (event) {
- var options = { transport: 'beacon' }
- var submittedForm = event.target
- var checkedOption = submittedForm.querySelector('input:checked')
- var eventValue = this.eventTrackingValue(checkedOption)
-
- GOVUK.analytics.trackEvent('Radio button chosen', eventValue, options)
-
- if (this.crossDomainTrackingEnabled(submittedForm)) {
- this.trackCrossDomainEvent(submittedForm, eventValue, options)
- }
- }.bind(this))
- }
-
- TrackRadioGroup.prototype.eventTrackingValue = function (element) {
- var value = null
-
- if (typeof element === 'undefined' || element === null) {
- value = 'submitted-without-choosing'
- } else {
- value = element.value
- }
- return value
- }
-
- TrackRadioGroup.prototype.addCrossDomainTracking = function (element) {
- var code = element.getAttribute('data-tracking-code')
- var domain = element.getAttribute('data-tracking-domain')
- var name = element.getAttribute('data-tracking-name')
-
- GOVUK.analytics.addLinkedTrackerDomain(code, name, domain)
- }
-
- TrackRadioGroup.prototype.trackCrossDomainEvent = function (element, eventValue, options) {
- var name = element.getAttribute('data-tracking-name')
- if (name) {
- options.trackerName = name
- }
-
- GOVUK.analytics.trackEvent('Radio button chosen', eventValue, options)
- }
-
- TrackRadioGroup.prototype.crossDomainTrackingEnabled = function (element) {
- return (
- element.getAttribute('data-tracking-code') &&
- element.getAttribute('data-tracking-domain') &&
- element.getAttribute('data-tracking-name')
- )
- }
-
- Modules.TrackRadioGroup = TrackRadioGroup
-})(window.GOVUK.Modules)
diff --git a/app/views/content_items/service_sign_in/_choose_sign_in.html.erb b/app/views/content_items/service_sign_in/_choose_sign_in.html.erb
index 3ea02d8c6..34a051f2a 100644
--- a/app/views/content_items/service_sign_in/_choose_sign_in.html.erb
+++ b/app/views/content_items/service_sign_in/_choose_sign_in.html.erb
@@ -13,15 +13,8 @@
<% end %>
-<%
- data_attrs = { module: "track-radio-group" }
- data_attrs["tracking-code"] = @content_item.tracking_code if @content_item.tracking_code
- data_attrs["tracking-domain"] = @content_item.tracking_domain if @content_item.tracking_domain
- data_attrs["tracking-name"] = @content_item.tracking_name if @content_item.tracking_name
-%>
<%= form_tag({controller: 'content_items', action: 'service_sign_in_options'},
- method: "post",
- data: data_attrs) do %>
+ method: "post") do %>
<% legend_text = render 'govuk_publishing_components/components/title', title: @content_item.title %>
<% description_text = render 'govuk_publishing_components/components/govspeak' do %>
<% raw(@content_item.description) %>
diff --git a/spec/javascripts/track-radio-group.spec.js b/spec/javascripts/track-radio-group.spec.js
deleted file mode 100644
index abc9009e6..000000000
--- a/spec/javascripts/track-radio-group.spec.js
+++ /dev/null
@@ -1,87 +0,0 @@
-var $ = window.jQuery
-
-describe('A radio group tracker', function () {
- var GOVUK = window.GOVUK
- var tracker
- var element
-
- GOVUK.analytics = GOVUK.analytics || {}
- GOVUK.analytics.trackEvent = function () {}
- GOVUK.analytics.addLinkedTrackerDomain = function () {}
-
- beforeEach(function () {
- spyOn(GOVUK.analytics, 'trackEvent')
-
- element = $(
- ''
- )
-
- $('body').append(element)
-
- tracker = new GOVUK.Modules.TrackRadioGroup(element[0])
- tracker.init()
- })
-
- afterEach(function () {
- element.remove()
- })
-
- it('tracks government-gateway checked radio when clicking submit', function () {
- element.find('input[value="government-gateway"]').trigger('click')
- element.find('button').trigger('click')
-
- expect(GOVUK.analytics.trackEvent).toHaveBeenCalledWith(
- 'Radio button chosen', 'government-gateway', { transport: 'beacon' }
- )
- })
-
- it('tracks govuk-verify checked radio when clicking submit', function () {
- element.find('input[value="govuk-verify"]').trigger('click')
- element.find('button').trigger('click')
-
- expect(GOVUK.analytics.trackEvent).toHaveBeenCalledWith(
- 'Radio button chosen', 'govuk-verify', { transport: 'beacon' }
- )
- })
-
- it('tracks no choice when clicking submit and checked nothing', function () {
- element.find('button').trigger('click')
-
- expect(GOVUK.analytics.trackEvent).toHaveBeenCalledWith(
- 'Radio button chosen', 'submitted-without-choosing', { transport: 'beacon' }
- )
- })
-
- describe('cross domain tracking enabled', function () {
- beforeEach(function () {
- spyOn(GOVUK.analytics, 'addLinkedTrackerDomain')
-
- element.attr('data-tracking-code', 'UA-xxxxxx')
- element.attr('data-tracking-domain', 'test.service.gov.uk')
- element.attr('data-tracking-name', 'testTracker')
-
- tracker = new GOVUK.Modules.TrackRadioGroup(element[0])
- tracker.init()
- })
-
- it('adds a linked tracker as the module is started', function () {
- expect(GOVUK.analytics.addLinkedTrackerDomain).toHaveBeenCalledWith(
- 'UA-xxxxxx', 'testTracker', 'test.service.gov.uk'
- )
- })
-
- it('sends an event to the linked tracker when the form is submitted', function () {
- element.find('input[value="govuk-verify"]').trigger('click')
- element.find('button').trigger('click')
-
- expect(GOVUK.analytics.trackEvent).toHaveBeenCalledWith(
- 'Radio button chosen', 'govuk-verify', { trackerName: 'testTracker', transport: 'beacon' }
- )
- })
- })
-})
diff --git a/test/integration/service_sign_in/choose_sign_in_test.rb b/test/integration/service_sign_in/choose_sign_in_test.rb
index f1bacd78c..bc80ccb79 100644
--- a/test/integration/service_sign_in/choose_sign_in_test.rb
+++ b/test/integration/service_sign_in/choose_sign_in_test.rb
@@ -20,10 +20,6 @@ class ChooseSignInTest < ActionDispatch::IntegrationTest
assert_not page.has_css?("#proposition-menu")
assert page.has_css?('.gem-c-back-link[href="/log-in-file-self-assessment-tax-return"]', text: "Back")
- assert page.has_css?('form[data-module="track-radio-group"]')
- assert page.has_css?("form[data-tracking-code='UA-xxxxxx']")
- assert page.has_css?("form[data-tracking-domain='tax.service.gov.uk']")
- assert page.has_css?("form[data-tracking-name='somethingClicky']")
within "#content form" do
within ".gem-c-fieldset" do
From 7885215770cd134f4efee4ca52cfcf5d49c16284 Mon Sep 17 00:00:00 2001
From: AshGDS <8880610+AshGDS@users.noreply.github.com>
Date: Fri, 28 Jun 2024 12:28:29 +0100
Subject: [PATCH 3/7] Remove UA from webchat
---
app/assets/javascripts/webchat/library.js | 13 -------
spec/javascripts/webchat.spec.js | 42 ++---------------------
2 files changed, 2 insertions(+), 53 deletions(-)
diff --git a/app/assets/javascripts/webchat/library.js b/app/assets/javascripts/webchat/library.js
index 3021b7bc2..9efae07c2 100644
--- a/app/assets/javascripts/webchat/library.js
+++ b/app/assets/javascripts/webchat/library.js
@@ -1,6 +1,4 @@
(function (global) {
- var GOVUK = global.GOVUK || {}
-
function Webchat (el) {
var POLL_INTERVAL = 5 * 1000
var AJAX_TIMEOUT = 5 * 1000
@@ -17,7 +15,6 @@
var openButton = document.querySelector('.js-webchat-open-button')
var webchatStateClass = 'js-webchat-advisers-'
var intervalID = null
- var lastRecordedState = null
function init () {
if (!availabilityUrl || !openUrl) {
@@ -35,7 +32,6 @@
evt.preventDefault()
var redirect = this.getAttribute('data-redirect')
redirect === 'true' ? window.location.href = openUrl : window.open(openUrl, 'newwin', 'width=366,height=516')
- trackEvent('opened')
}
function checkAvailability () {
@@ -104,15 +100,6 @@
allStates[index].classList.add('govuk-!-display-none')
}
currentState.classList.remove('govuk-!-display-none')
- trackEvent(state)
- }
-
- function trackEvent (state) {
- state = state.toLowerCase()
- if (lastRecordedState === state) return
-
- GOVUK.analytics.trackEvent('webchat', state)
- lastRecordedState = state
}
init()
diff --git a/spec/javascripts/webchat.spec.js b/spec/javascripts/webchat.spec.js
index 77860ec4e..147295cfb 100644
--- a/spec/javascripts/webchat.spec.js
+++ b/spec/javascripts/webchat.spec.js
@@ -1,13 +1,10 @@
-/* globals lolex, setFixtures */
+/* globals setFixtures */
var $ = window.jQuery
-var POLL_INTERVAL = '6' // Offset by one
describe('Webchat', function () {
var GOVUK = window.GOVUK
- // Stub analytics.
- GOVUK.analytics = GOVUK.analytics || {}
- GOVUK.analytics.trackEvent = function () {}
+
var CHILD_BENEFIT_API_URL = 'https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006859&siteID=10006719&businessUnitID=19001235'
var INSERTION_HOOK = '' +
@@ -108,40 +105,5 @@ describe('Webchat', function () {
expect($advisersBusy.hasClass('govuk-!-display-none')).toBe(true)
expect($advisersUnavailable.hasClass('govuk-!-display-none')).toBe(true)
})
-
- it('should only track once per state change', function () {
- var analyticsExpects = ['available', 'error']
- var analyticsReceived = []
- var analyticsCalled = 0
- var clock = lolex.install()
-
- spyOn(GOVUK.analytics, 'trackEvent').and.callFake(function (webchatKey, webchatValue) {
- analyticsReceived.push(webchatValue)
- analyticsCalled++
- })
-
- mount()
- jasmine.Ajax.requests.mostRecent().respondWith(jsonNormalisedAvailable)
-
- expect($advisersAvailable.hasClass('govuk-!-display-none')).toBe(false)
-
- expect($advisersBusy.hasClass('govuk-!-display-none')).toBe(true)
- expect($advisersError.hasClass('govuk-!-display-none')).toBe(true)
- expect($advisersUnavailable.hasClass('govuk-!-display-none')).toBe(true)
-
- clock.tick(POLL_INTERVAL)
- jasmine.Ajax.requests.mostRecent().respondWith(jsonNormalisedError)
-
- expect($advisersError.hasClass('govuk-!-display-none')).toBe(false)
- expect($advisersAvailable.hasClass('govuk-!-display-none')).toBe(true)
- expect($advisersBusy.hasClass('govuk-!-display-none')).toBe(true)
- expect($advisersUnavailable.hasClass('govuk-!-display-none')).toBe(true)
- expect(analyticsCalled).toBe(2)
- expect(analyticsReceived).toEqual(analyticsExpects)
- clock.tick(POLL_INTERVAL)
- expect(analyticsCalled).toBe(2)
- expect(analyticsReceived).toEqual(analyticsExpects)
- clock.uninstall()
- })
})
})
From 8973e8e9cb5f5437c8295db204c6f57760685c6c Mon Sep 17 00:00:00 2001
From: AshGDS <8880610+AshGDS@users.noreply.github.com>
Date: Fri, 28 Jun 2024 12:49:16 +0100
Subject: [PATCH 4/7] Remove UA from content_items
---
app/controllers/content_items_controller.rb | 12 +----
app/views/content_items/answer.html.erb | 14 -----
.../content_items/detailed_guide.html.erb | 51 -------------------
app/views/content_items/guide.html+print.erb | 10 ----
app/views/content_items/guide.html.erb | 23 ---------
.../content_items/html_publication.html.erb | 10 ----
app/views/content_items/publication.html.erb | 9 ----
.../travel_advice.html+print.erb | 10 ----
.../content_items/travel_advice.html.erb | 16 ++----
9 files changed, 7 insertions(+), 148 deletions(-)
diff --git a/app/controllers/content_items_controller.rb b/app/controllers/content_items_controller.rb
index 7d62d34bc..fce914e36 100644
--- a/app/controllers/content_items_controller.rb
+++ b/app/controllers/content_items_controller.rb
@@ -156,19 +156,11 @@ def ordered_related_items(links)
)
end
- def format_banner_links(links, type)
- links.each.with_index(1).map do |(title, base_path), index|
+ def format_banner_links(links)
+ links.each.map do |(title, base_path)|
view_context.link_to(
title,
base_path,
- data: {
- "track-category": "relatedTaxonomyLinkClicked",
- "track-action": "1.#{index} #{type}",
- "track-label": base_path,
- "track-options": {
- dimension29: title,
- },
- },
)
end
end
diff --git a/app/views/content_items/answer.html.erb b/app/views/content_items/answer.html.erb
index 006de7f60..13b1c11b5 100644
--- a/app/views/content_items/answer.html.erb
+++ b/app/views/content_items/answer.html.erb
@@ -3,20 +3,6 @@
schema: :faq
) %>
- <%
- scroll_track_headings_paths = [
- "/wood-packaging-import-export",
- ]
- scroll_track_percent_paths = [
- "/get-coronavirus-test",
- ]
- %>
- <% if scroll_track_headings_paths.include?(@content_item.base_path) %>
-
- <% elsif scroll_track_percent_paths.include?(@content_item.base_path) %>
-
- <% end %>
-
<%= @requested_variant.analytics_meta_tag.html_safe if @requested_variant.present? %>
<% end %>
diff --git a/app/views/content_items/detailed_guide.html.erb b/app/views/content_items/detailed_guide.html.erb
index d8871bb29..2ec31a688 100644
--- a/app/views/content_items/detailed_guide.html.erb
+++ b/app/views/content_items/detailed_guide.html.erb
@@ -2,57 +2,6 @@
<%= machine_readable_metadata(
schema: :faq
) %>
-
- <%
- scroll_track_headings_paths = [
- "/guidance/universal-credit-how-it-helps-you-into-work",
- "/guidance/returning-to-the-uk",
- "/guidance/foreign-travel-insurance",
- "/guidance/living-in-france",
- "/guidance/healthcare-for-eu-and-efta-citizens-visiting-the-uk",
- "/guidance/guidance-for-suppliers-of-cattle-sheep-and-goat-ear-tags",
- "/guidance/ecmt-international-road-haulage-permits",
- ]
- scroll_track_percent_paths = [
- "/guidance/import-and-export-goods-using-preference-agreements",
- "/guidance/financial-evidence-for-sponsored-or-endorsed-work-routes",
- ]
- %>
- <% if scroll_track_headings_paths.include?(@content_item.base_path) %>
-
- <% elsif @content_item.base_path == "/guidance/travel-to-england-from-another-country-during-coronavirus-covid-19" %>
- <%
- headings = [
- "Applies to England",
- "If you are fully vaccinated",
- "Check if you qualify as fully vaccinated",
- "Travelling with children",
- "Ireland, the UK, the Channel Islands and the Isle of Man",
- "If you are not fully vaccinated",
- "Travel abroad from England",
- "Red list countries and territories",
- "Transiting through England",
- ]
- %>
- <%= tag.meta name: "govuk-scroll-tracker", content: "", data: { module: "auto-scroll-tracker", "track-type": "headings", "track-headings": headings.to_json } %>
- <% elsif @content_item.base_path == "/guidance/travel-abroad-from-england-during-coronavirus-covid-19" %>
- <%
- headings = [
- "Applies to England",
- "Travelling with children",
- "1. Check foreign travel advice for the countries you want to go to",
- "Ireland, the UK, the Channel Islands and the Isle of Man",
- "2. Arrange any COVID-19 tests you will need to enter the countries that you will travel to",
- "3. Find out how you can use the NHS COVID Pass to prove your vaccination status abroad",
- "Exemptions for work, medical or compassionate reasons",
- "4. Check what you will need to do when you return to England",
- "Travel to England guidance",
- ]
- %>
- <%= tag.meta name: "govuk-scroll-tracker", content: "", data: { module: "auto-scroll-tracker", "track-type": "headings", "track-headings": headings.to_json } %>
- <% elsif scroll_track_percent_paths.include?(@content_item.base_path) %>
-
- <% end %>
<% end %>
<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.title_and_context[:title] } %>
diff --git a/app/views/content_items/guide.html+print.erb b/app/views/content_items/guide.html+print.erb
index 4647b5d89..f2cd2b38f 100644
--- a/app/views/content_items/guide.html+print.erb
+++ b/app/views/content_items/guide.html+print.erb
@@ -21,11 +21,6 @@
<%= render 'govuk_publishing_components/components/print_link', {
- data_attributes: {
- "track-category": "printButton",
- "track-action": "clicked",
- "track-label": t("components.print_link.text"),
- },
margin_bottom: 8,
text: t("components.print_link.text"),
} %>
@@ -44,11 +39,6 @@
<% end %>
<%= render 'govuk_publishing_components/components/print_link', {
- data_attributes: {
- "track-category": "printButton",
- "track-action": "clicked",
- "track-label": t("components.print_link.text"),
- },
text: t("components.print_link.text")
} %>
diff --git a/app/views/content_items/guide.html.erb b/app/views/content_items/guide.html.erb
index ec0cc7734..614fa014e 100644
--- a/app/views/content_items/guide.html.erb
+++ b/app/views/content_items/guide.html.erb
@@ -6,29 +6,6 @@
body: @content_item.has_parts? ? @content_item.current_part_body : nil
) %>
- <%
- scroll_track_headings_paths = [
- "/council-housing",
- "/driving-abroad",
- "/get-a-passport-urgently",
- "/driving-abroad/international-driving-permit",
- "/taking-goods-out-uk-temporarily/get-an-ata-carnet",
- ]
-
- scroll_track_percent_paths = [
- "/skilled-worker-visa",
- "/skilled-worker-visa/documents-you-must-provide",
- "/apply-to-come-to-the-uk",
- ]
-
- full_url = [@content_item.base_path, @content_item.part_slug].compact.join('/')
- %>
- <% if scroll_track_headings_paths.include?(full_url) %>
-
- <% elsif scroll_track_percent_paths.include?(@content_item.base_path) %>
-
- <% end %>
-
<%= @requested_variant.analytics_meta_tag.html_safe if @requested_variant.present? %>
<% end %>
diff --git a/app/views/content_items/html_publication.html.erb b/app/views/content_items/html_publication.html.erb
index d968b38f2..af2904560 100644
--- a/app/views/content_items/html_publication.html.erb
+++ b/app/views/content_items/html_publication.html.erb
@@ -3,16 +3,6 @@
<%= machine_readable_metadata(
schema: :html_publication
) %>
-
- <%
- scroll_track_headings_paths = [
- "/government/publications/the-essential-trustee-what-you-need-to-know-cc3/the-essential-trustee-what-you-need-to-know-what-you-need-to-do",
- "/government/publications/spring-budget-2017-documents/spring-budget-2017",
- ]
- %>
- <% if scroll_track_headings_paths.include?(@content_item.base_path) %>
-
- <% end %>
<% end %>
<%
diff --git a/app/views/content_items/publication.html.erb b/app/views/content_items/publication.html.erb
index 293c4ed7c..8ffbcc9ff 100644
--- a/app/views/content_items/publication.html.erb
+++ b/app/views/content_items/publication.html.erb
@@ -2,15 +2,6 @@
<%= machine_readable_metadata(
schema: (@content_item.dataset? ? :dataset : :article)
) %>
-
- <%
- # As per request https://govuk.zendesk.com/agent/tickets/5176602
- scroll_track_paths = %w[/government/publications/form-pa14-medical-certificate-probate /government/publications/find-a-will-or-probate-document-form-pa1s /government/publications/report-a-will-is-lost-to-support-a-probate-application]
- %>
-
- <% if scroll_track_paths.include?(@content_item.base_path) %>
-
- <% end %>
<% end %>
<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.title } %>
diff --git a/app/views/content_items/travel_advice.html+print.erb b/app/views/content_items/travel_advice.html+print.erb
index 7d4ff303b..f6a96461b 100644
--- a/app/views/content_items/travel_advice.html+print.erb
+++ b/app/views/content_items/travel_advice.html+print.erb
@@ -20,11 +20,6 @@
<%= render 'govuk_publishing_components/components/print_link', {
- data_attributes: {
- "track-category": "printButton",
- "track-action": "clicked",
- "track-label": t("components.print_link.text"),
- },
margin_bottom: 8,
text: t("components.print_link.text"),
} %>
@@ -44,11 +39,6 @@
<% end %>
<%= render 'govuk_publishing_components/components/print_link', {
- data_attributes: {
- "track-category": "printButton",
- "track-action": "clicked",
- "track-label": t("components.print_link.text"),
- },
text: t("components.print_link.text")
} %>
diff --git a/app/views/content_items/travel_advice.html.erb b/app/views/content_items/travel_advice.html.erb
index 608d054e3..2fe5ee7de 100644
--- a/app/views/content_items/travel_advice.html.erb
+++ b/app/views/content_items/travel_advice.html.erb
@@ -51,17 +51,11 @@
<%= render 'shared/travel_advice_first_part', content_item: @content_item %>
<% end %>
-
- <%= render 'govuk_publishing_components/components/govspeak', {
- direction: page_text_direction,
- } do %>
- <%= raw(@content_item.current_part_body) %>
- <% end %>
-
+ <%= render 'govuk_publishing_components/components/govspeak', {
+ direction: page_text_direction,
+ } do %>
+ <%= raw(@content_item.current_part_body) %>
+ <% end %>
<%= render 'govuk_publishing_components/components/previous_and_next_navigation', @content_item.previous_and_next_navigation %>
From 1e9bf899b24cdafbc1c01ed76a9b5b4c0ae80f88 Mon Sep 17 00:00:00 2001
From: AshGDS <8880610+AshGDS@users.noreply.github.com>
Date: Fri, 28 Jun 2024 14:46:37 +0100
Subject: [PATCH 5/7] Remove UA from presenters
---
app/presenters/content_item/parts.rb | 8 +---
.../document_collection_presenter.rb | 13 +-----
.../_document_collection_body.html.erb | 6 +--
...document_collections_email_signup.html.erb | 6 ---
test/integration/document_collection_test.rb | 42 -------------------
test/presenters/content_item/parts_test.rb | 25 ++---------
.../document_collection_presenter_test.rb | 16 +------
.../travel_advice_presenter_test.rb | 24 -----------
8 files changed, 11 insertions(+), 129 deletions(-)
diff --git a/app/presenters/content_item/parts.rb b/app/presenters/content_item/parts.rb
index df9c9444d..a2cf3bb01 100644
--- a/app/presenters/content_item/parts.rb
+++ b/app/presenters/content_item/parts.rb
@@ -84,18 +84,12 @@ def current_part
end
def part_links
- parts.map.with_index(1) do |part, position|
+ parts.map do |part|
if part["slug"] != current_part["slug"]
view_context.link_to(
part["title"],
part["full_path"],
class: "govuk-link",
- data: {
- track_category: "contentsClicked",
- track_action: "content_item #{position}",
- track_label: part["full_path"],
- track_options: { dimension29: part["title"] },
- },
)
else
part["title"]
diff --git a/app/presenters/document_collection_presenter.rb b/app/presenters/document_collection_presenter.rb
index 79be8e2bb..d94fb03b1 100644
--- a/app/presenters/document_collection_presenter.rb
+++ b/app/presenters/document_collection_presenter.rb
@@ -24,21 +24,12 @@ def groups
end
end
- def group_document_links(group, group_index)
- group_documents(group).each_with_index.map do |link, link_index|
+ def group_document_links(group)
+ group_documents(group).each.map do |link|
{
link: {
text: link["title"],
path: link["base_path"],
- data_attributes: {
- track_category: "navDocumentCollectionLinkClicked",
- track_action: "#{group_index + 1}.#{link_index + 1}",
- track_label: link["base_path"],
- track_options: {
- dimension28: group["documents"].count.to_s,
- dimension29: link["title"],
- },
- },
},
metadata: {
public_updated_at: group_document_link_public_updated_at(link),
diff --git a/app/views/content_items/_document_collection_body.html.erb b/app/views/content_items/_document_collection_body.html.erb
index 513d6f0e5..93a464a26 100644
--- a/app/views/content_items/_document_collection_body.html.erb
+++ b/app/views/content_items/_document_collection_body.html.erb
@@ -4,7 +4,7 @@
<% end %>
-<% @content_item.groups.each_with_index do |group, group_index| %>
+<% @content_item.groups.each do |group| %>
<%= @content_item.group_heading(group) %>
<% if group["body"].present? %>
@@ -15,7 +15,7 @@
<% end %>
<% end %>
-
- <%= render 'govuk_publishing_components/components/document_list', items: @content_item.group_document_links(group, group_index) %>
+
+ <%= render 'govuk_publishing_components/components/document_list', items: @content_item.group_document_links(group) %>
<% end %>
diff --git a/app/views/shared/_document_collections_email_signup.html.erb b/app/views/shared/_document_collections_email_signup.html.erb
index fa887ad5a..ca877ccc4 100644
--- a/app/views/shared/_document_collections_email_signup.html.erb
+++ b/app/views/shared/_document_collections_email_signup.html.erb
@@ -7,12 +7,6 @@
<%= render "govuk_publishing_components/components/signup_link", {
link_text: "Get emails about this topic",
link_href: "/email-signup/confirm?topic=#{@content_item.taxonomy_topic_email_override_base_path}",
- data: {
- "module": "gem-track-click",
- "track-category": "emailAlertLinkClicked",
- "track-action": @content_item.taxonomy_topic_email_override_base_path,
- "track-label": ""
- },
margin_bottom: 6
} %>
diff --git a/test/integration/document_collection_test.rb b/test/integration/document_collection_test.rb
index 21f93cd7b..d6caaaf00 100644
--- a/test/integration/document_collection_test.rb
+++ b/test/integration/document_collection_test.rb
@@ -93,48 +93,6 @@ class DocumentCollectionTest < ActionDispatch::IntegrationTest
end
end
- test "includes tracking data on all collection documents" do
- setup_and_visit_content_item("document_collection")
- groups = page.all(".gem-c-document-list")
- assert page.has_css?('[data-module="gem-track-click"]'), count: groups.length
-
- first_section_links = groups.first.all(:link)
- first_link = first_section_links.first
-
- assert_equal(
- "navDocumentCollectionLinkClicked",
- first_link["data-track-category"],
- "Expected a tracking category to be set in the data attributes",
- )
-
- assert_equal(
- "1.1",
- first_link["data-track-action"],
- "Expected the link position to be set in the data attributes",
- )
-
- assert_match(
- first_link["data-track-label"],
- first_link[:href],
- "Expected the content item base path to be set in the data attributes",
- )
- assert first_link["data-track-options"].present?
-
- data_options = JSON.parse(first_link["data-track-options"])
-
- assert_equal(
- first_section_links.count.to_s,
- data_options["dimension28"],
- "Expected the total number of content items within the section to be present in the tracking options",
- )
-
- assert_equal(
- first_link.text,
- data_options["dimension29"],
- "Expected the subtopic title to be present in the tracking options",
- )
- end
-
test "withdrawn collection" do
setup_and_visit_content_item("document_collection_withdrawn")
assert page.has_css?("title", text: "[Withdrawn]", visible: false)
diff --git a/test/presenters/content_item/parts_test.rb b/test/presenters/content_item/parts_test.rb
index 19fb22e85..8db010f24 100644
--- a/test/presenters/content_item/parts_test.rb
+++ b/test/presenters/content_item/parts_test.rb
@@ -152,19 +152,6 @@ def requested_path
assert_equal @parts.current_part_title, "first-title"
end
- test "navigation items are presented as trackable links unless they are the current part" do
- presenting_first_part_in_content_item
- assert_equal @parts.current_part_title, "first-title"
- assert_equal @parts.parts_navigation,
- [[
- "first-title",
- "second-title",
- ]]
- end
-
test "links to the first part ignore the part's slug and use the base path" do
presenting_second_part_in_content_item
assert_equal @parts.current_part_title, "second-title"
@@ -218,19 +205,13 @@ def content_item
[
[
"first-title",
- "second-title",
],
[
- "third-title",
- "fourth-title",
],
]
diff --git a/test/presenters/document_collection_presenter_test.rb b/test/presenters/document_collection_presenter_test.rb
index d166b929f..35d5c13f2 100644
--- a/test/presenters/document_collection_presenter_test.rb
+++ b/test/presenters/document_collection_presenter_test.rb
@@ -53,15 +53,6 @@ class PresentedDocumentCollection < TestCase
link: {
text: "National standard for driving cars and light vans",
path: "/government/publications/national-standard-for-driving-cars-and-light-vans",
- data_attributes: {
- track_category: "navDocumentCollectionLinkClicked",
- track_action: "1.1",
- track_label: "/government/publications/national-standard-for-driving-cars-and-light-vans",
- track_options: {
- dimension28: "1",
- dimension29: "National standard for driving cars and light vans",
- },
- },
},
metadata: {
public_updated_at: Time.zone.parse("2007-03-16 15:00:02 +0000"),
@@ -71,7 +62,7 @@ class PresentedDocumentCollection < TestCase
]
document_ids = schema_item["details"]["collection_groups"].first["documents"]
- assert_equal documents, presented_item.group_document_links({ "documents" => [document_ids.first] }, 0)
+ assert_equal documents, presented_item.group_document_links({ "documents" => [document_ids.first] })
end
test "it handles the document type lacking a translation" do
@@ -83,7 +74,6 @@ class PresentedDocumentCollection < TestCase
grouped = present_example(schema_data).group_document_links(
{ "documents" => [document["content_id"]] },
- 0,
)
assert_nil grouped.first[:metadata][:document_type]
@@ -98,7 +88,6 @@ class PresentedDocumentCollection < TestCase
grouped = present_example(schema_data).group_document_links(
{ "documents" => [document["content_id"]] },
- 0,
)
assert_nil grouped.first[:metadata][:public_updated_at]
@@ -123,7 +112,6 @@ class PresentedDocumentCollection < TestCase
grouped = present_example(schema_data).group_document_links(
{ "documents" => [document["content_id"]] },
- 0,
)
public_updated_at = grouped[0][:metadata][:public_updated_at]
@@ -143,7 +131,7 @@ class GroupWithMissingDocument < TestCase
.select { |g| g["title"] == "One document missing from links" }
.first
- presented_links = presenter.group_document_links(group_with_missing_document, 0)
+ presented_links = presenter.group_document_links(group_with_missing_document)
presented_links_base_paths = presented_links.collect { |link| link[:link][:path] }
assert_equal(
diff --git a/test/presenters/travel_advice_presenter_test.rb b/test/presenters/travel_advice_presenter_test.rb
index 49a33e77c..c694e1543 100644
--- a/test/presenters/travel_advice_presenter_test.rb
+++ b/test/presenters/travel_advice_presenter_test.rb
@@ -82,30 +82,6 @@ def schema_name
assert_equal "Summary", first_nav_item
end
- test "navigation items are presented as trackable links unless they are the current part" do
- example = schema_item("full-country")
- current_part = example["details"]["parts"][1]
-
- first_part_presented = presented_item("full-country", current_part["slug"])
- navigation_items = first_part_presented.parts_navigation
-
- first_part_nav_item = navigation_items[0][0]
- current_part_nav_item = navigation_items[0][1]
- another_part_nav_item = navigation_items[0][2]
-
- assert_equal first_part_nav_item,
- "Summary"
- assert_equal current_part_nav_item, current_part["title"]
- assert_equal another_part_nav_item,
- "Terrorism"
- end
-
test "navigation items link to all parts" do
parts = schema_item("full-country")["details"]["parts"]
part_links = presented_item("full-country").parts_navigation.flatten
From c881811fcba39c19c33b192e10db6751658488ea Mon Sep 17 00:00:00 2001
From: AshGDS <8880610+AshGDS@users.noreply.github.com>
Date: Fri, 28 Jun 2024 15:16:18 +0100
Subject: [PATCH 6/7] Namespace a function with ga4
---
test/integration/consultation_test.rb | 4 ++--
test/integration/detailed_guide_test.rb | 4 ++--
test/integration/publication_test.rb | 4 ++--
test/test_helper.rb | 2 +-
4 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/test/integration/consultation_test.rb b/test/integration/consultation_test.rb
index 24f5d51d5..a1ba7e8a3 100644
--- a/test/integration/consultation_test.rb
+++ b/test/integration/consultation_test.rb
@@ -378,11 +378,11 @@ class ConsultationTest < ActionDispatch::IntegrationTest
buttons = page.find_all(:button)
- expected_tracking_top = single_page_notification_button_ga_tracking(1, "Top")
+ expected_tracking_top = single_page_notification_button_ga4_tracking(1, "Top")
actual_tracking_top = JSON.parse(buttons.first["data-ga4-link"])
assert_equal expected_tracking_top, actual_tracking_top
- expected_tracking_bottom = single_page_notification_button_ga_tracking(2, "Footer")
+ expected_tracking_bottom = single_page_notification_button_ga4_tracking(2, "Footer")
actual_tracking_bottom = JSON.parse(buttons.last["data-ga4-link"])
assert_equal expected_tracking_bottom, actual_tracking_bottom
end
diff --git a/test/integration/detailed_guide_test.rb b/test/integration/detailed_guide_test.rb
index 19e5afd47..94ba6c670 100644
--- a/test/integration/detailed_guide_test.rb
+++ b/test/integration/detailed_guide_test.rb
@@ -93,11 +93,11 @@ class DetailedGuideTest < ActionDispatch::IntegrationTest
buttons = page.find_all(:button)
- expected_tracking_top = single_page_notification_button_ga_tracking(1, "Top")
+ expected_tracking_top = single_page_notification_button_ga4_tracking(1, "Top")
actual_tracking_top = JSON.parse(buttons.first["data-ga4-link"])
assert_equal expected_tracking_top, actual_tracking_top
- expected_tracking_bottom = single_page_notification_button_ga_tracking(2, "Footer")
+ expected_tracking_bottom = single_page_notification_button_ga4_tracking(2, "Footer")
actual_tracking_bottom = JSON.parse(buttons.last["data-ga4-link"])
assert_equal expected_tracking_bottom, actual_tracking_bottom
end
diff --git a/test/integration/publication_test.rb b/test/integration/publication_test.rb
index db20a20c0..2e426a5b0 100644
--- a/test/integration/publication_test.rb
+++ b/test/integration/publication_test.rb
@@ -275,11 +275,11 @@ class PublicationTest < ActionDispatch::IntegrationTest
buttons = page.find_all(:button)
- expected_tracking_top = single_page_notification_button_ga_tracking(1, "Top")
+ expected_tracking_top = single_page_notification_button_ga4_tracking(1, "Top")
actual_tracking_top = JSON.parse(buttons.first["data-ga4-link"])
assert_equal expected_tracking_top, actual_tracking_top
- expected_tracking_bottom = single_page_notification_button_ga_tracking(2, "Footer")
+ expected_tracking_bottom = single_page_notification_button_ga4_tracking(2, "Footer")
actual_tracking_bottom = JSON.parse(buttons.last["data-ga4-link"])
assert_equal expected_tracking_bottom, actual_tracking_bottom
end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 64e0938d1..8bffc5940 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -272,7 +272,7 @@ def find_structured_data(page, schema_name)
schemas.detect { |schema| schema["@type"] == schema_name }
end
- def single_page_notification_button_ga_tracking(index_link, section)
+ def single_page_notification_button_ga4_tracking(index_link, section)
{
"event_name" => "navigation",
"type" => "subscribe",
From c7f6bf4af3213f93a3a1bbfbca77ec7be476b908 Mon Sep 17 00:00:00 2001
From: AshGDS <8880610+AshGDS@users.noreply.github.com>
Date: Mon, 1 Jul 2024 09:15:36 +0100
Subject: [PATCH 7/7] Remove UA from metadata template
---
app/views/components/_important_metadata.html.erb | 2 +-
test/components/important_metadata_test.rb | 5 -----
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/app/views/components/_important_metadata.html.erb b/app/views/components/_important_metadata.html.erb
index 1ffdc9f04..e136a55e4 100644
--- a/app/views/components/_important_metadata.html.erb
+++ b/app/views/components/_important_metadata.html.erb
@@ -11,7 +11,7 @@
<% if title %>
<% end %>
-
+
<% items.each do |title, definition| %>
- <%= sanitize title.to_s %>:
- <%= sanitize definition %>
diff --git a/test/components/important_metadata_test.rb b/test/components/important_metadata_test.rb
index 75d5a9c01..660c5d989 100644
--- a/test/components/important_metadata_test.rb
+++ b/test/components/important_metadata_test.rb
@@ -53,9 +53,4 @@ def component_name
assert_select ".app-c-important-metadata dd a[href='https://www.gov.uk/cma-cases?outcome_type%5B%5D=mergers-phase-2-clearance-with-remedies']",
text: "Mergers - phase 2 clearance with remedies"
end
-
- test "link tracking is enabled" do
- render_component(items: { "Case type": ["Mergers"] })
- assert_select ".app-c-important-metadata dl[data-module='gem-track-click']"
- end
end