From e88e66991d69401564541f05580c9d8016e96c7b Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Mon, 28 Nov 2022 14:39:21 +0000 Subject: [PATCH 1/2] Update for event tracker changes - GA4 event tracker has been rewritten to use a `data-ga-event` attribute in place of `data-ga4` - updating for tracking on various pages for print link --- .../content_items/detailed_guide.html.erb | 4 ++-- app/views/content_items/guide.html+print.erb | 4 ++-- app/views/content_items/hmrc_manual.html.erb | 2 +- .../hmrc_manual_section.html.erb | 2 +- .../content_items/html_publication.html.erb | 2 +- app/views/content_items/manual.html.erb | 2 +- .../content_items/manual_section.html.erb | 19 +++---------------- .../content_items/manuals/_updates.html.erb | 19 +++---------------- .../travel_advice.html+print.erb | 4 ++-- 9 files changed, 16 insertions(+), 42 deletions(-) diff --git a/app/views/content_items/detailed_guide.html.erb b/app/views/content_items/detailed_guide.html.erb index a7cc522b3..8dd0759e2 100644 --- a/app/views/content_items/detailed_guide.html.erb +++ b/app/views/content_items/detailed_guide.html.erb @@ -86,7 +86,7 @@ margin_bottom: 6, data_attributes: { module: "ga4-event-tracker", - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 1, @@ -109,7 +109,7 @@ margin_bottom: 6, data_attributes: { module: "ga4-event-tracker", - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 2, diff --git a/app/views/content_items/guide.html+print.erb b/app/views/content_items/guide.html+print.erb index d7b0b1255..9c9ae9bf5 100644 --- a/app/views/content_items/guide.html+print.erb +++ b/app/views/content_items/guide.html+print.erb @@ -25,7 +25,7 @@ "track-category": "printButton", "track-action": "clicked", "track-label": t("components.print_link.text"), - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 1, @@ -56,7 +56,7 @@ "track-category": "printButton", "track-action": "clicked", "track-label": t("components.print_link.text"), - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 2, diff --git a/app/views/content_items/hmrc_manual.html.erb b/app/views/content_items/hmrc_manual.html.erb index 1b1368b0c..d319a7701 100644 --- a/app/views/content_items/hmrc_manual.html.erb +++ b/app/views/content_items/hmrc_manual.html.erb @@ -27,7 +27,7 @@ <%= render 'govuk_publishing_components/components/print_link', { data_attributes: { module: "ga4-event-tracker", - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 1, diff --git a/app/views/content_items/hmrc_manual_section.html.erb b/app/views/content_items/hmrc_manual_section.html.erb index 390625ca6..9542a0fa5 100644 --- a/app/views/content_items/hmrc_manual_section.html.erb +++ b/app/views/content_items/hmrc_manual_section.html.erb @@ -48,7 +48,7 @@ <%= render 'govuk_publishing_components/components/print_link', { data_attributes: { module: "ga4-event-tracker", - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 1, diff --git a/app/views/content_items/html_publication.html.erb b/app/views/content_items/html_publication.html.erb index 9ac484472..f2a2275ad 100644 --- a/app/views/content_items/html_publication.html.erb +++ b/app/views/content_items/html_publication.html.erb @@ -60,7 +60,7 @@ margin_bottom: 6, data_attributes: { module: "ga4-event-tracker", - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 1, diff --git a/app/views/content_items/manual.html.erb b/app/views/content_items/manual.html.erb index b514cef96..e350d7912 100644 --- a/app/views/content_items/manual.html.erb +++ b/app/views/content_items/manual.html.erb @@ -36,7 +36,7 @@ <%= render 'govuk_publishing_components/components/print_link', { data_attributes: { module: "ga4-event-tracker", - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 1, diff --git a/app/views/content_items/manual_section.html.erb b/app/views/content_items/manual_section.html.erb index dd3e0031d..fc047fe1c 100644 --- a/app/views/content_items/manual_section.html.erb +++ b/app/views/content_items/manual_section.html.erb @@ -61,7 +61,7 @@ { data_attributes: { - ga4: { + ga4_event: { event_name: "select_content", type: "accordion", text: item[:heading][:text], @@ -77,21 +77,8 @@ end %> - <% - ga4_attributes = { - event_name: "select_content", - type: "accordion", - index: 0, - index_total: @content_item.main.length, - } - %> <%= render "govuk_publishing_components/components/accordion", { - data_attributes_show_all: { - "ga4": ga4_attributes.to_json - }, - data_attributes: { - module: "ga4-event-tracker", - }, + ga4_tracking: true, anchor_navigation: true, items: items, } %> @@ -105,7 +92,7 @@ <%= render 'govuk_publishing_components/components/print_link', { data_attributes: { module: "ga4-event-tracker", - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 1, diff --git a/app/views/content_items/manuals/_updates.html.erb b/app/views/content_items/manuals/_updates.html.erb index 5183d99d0..56893889c 100644 --- a/app/views/content_items/manuals/_updates.html.erb +++ b/app/views/content_items/manuals/_updates.html.erb @@ -18,22 +18,9 @@ font_size: "l" } %> - <% - show_all_attributes = { - event_name: "select_content", - type: "accordion", - index: 0, - index_total: updates_by_year.length, - } - %> <%= render "govuk_publishing_components/components/accordion", { heading_level: 3, - data_attributes: { - module: "ga4-event-tracker", - }, - data_attributes_show_all: { - "ga4": show_all_attributes.to_json - }, + ga4_tracking: true, items: updates_by_year.each.with_index(1).map do |updated_documents, index| accordion_content = capture do %> <% change_notes = updated_documents.last %> @@ -49,7 +36,7 @@ <% end { data_attributes: { - ga4: { + ga4_event: { event_name: 'select_content', type: 'accordion', text: sanitize_manual_update_title(updated_documents.first), @@ -75,7 +62,7 @@ <%= render 'govuk_publishing_components/components/print_link', { data_attributes: { module: "ga4-event-tracker", - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 1, diff --git a/app/views/content_items/travel_advice.html+print.erb b/app/views/content_items/travel_advice.html+print.erb index e0f3ab0ba..370e726ff 100644 --- a/app/views/content_items/travel_advice.html+print.erb +++ b/app/views/content_items/travel_advice.html+print.erb @@ -24,7 +24,7 @@ "track-category": "printButton", "track-action": "clicked", "track-label": t("components.print_link.text"), - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 1, @@ -56,7 +56,7 @@ "track-category": "printButton", "track-action": "clicked", "track-label": t("components.print_link.text"), - ga4: { + ga4_event: { event_name: 'print_page', type: 'Print this page', index: 2, From 74204f8ab26a253d1b31aa9b5c7cd984bb5a0694 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Tue, 29 Nov 2022 09:23:07 +0000 Subject: [PATCH 2/2] Update print link tracking - changes some values for print link tracking in GA4 --- app/views/content_items/detailed_guide.html.erb | 6 +++--- app/views/content_items/guide.html+print.erb | 6 +++--- app/views/content_items/hmrc_manual.html.erb | 2 +- app/views/content_items/hmrc_manual_section.html.erb | 2 +- app/views/content_items/html_publication.html.erb | 4 ++-- app/views/content_items/manual.html.erb | 2 +- app/views/content_items/manual_section.html.erb | 2 +- app/views/content_items/manuals/_updates.html.erb | 2 +- app/views/content_items/travel_advice.html+print.erb | 6 +++--- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/app/views/content_items/detailed_guide.html.erb b/app/views/content_items/detailed_guide.html.erb index 8dd0759e2..c77b38648 100644 --- a/app/views/content_items/detailed_guide.html.erb +++ b/app/views/content_items/detailed_guide.html.erb @@ -88,10 +88,10 @@ module: "ga4-event-tracker", ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 1, index_total: 2, - section: 'Contents', + section: 'Content', }, }, } %> @@ -111,7 +111,7 @@ module: "ga4-event-tracker", ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 2, index_total: 2, section: 'Footer', diff --git a/app/views/content_items/guide.html+print.erb b/app/views/content_items/guide.html+print.erb index 9c9ae9bf5..172f81cde 100644 --- a/app/views/content_items/guide.html+print.erb +++ b/app/views/content_items/guide.html+print.erb @@ -27,10 +27,10 @@ "track-label": t("components.print_link.text"), ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 1, index_total: 2, - section: 'Contents', + section: 'Content', }, }, margin_bottom: 8, @@ -58,7 +58,7 @@ "track-label": t("components.print_link.text"), ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 2, index_total: 2, section: 'Footer', diff --git a/app/views/content_items/hmrc_manual.html.erb b/app/views/content_items/hmrc_manual.html.erb index d319a7701..54c68275c 100644 --- a/app/views/content_items/hmrc_manual.html.erb +++ b/app/views/content_items/hmrc_manual.html.erb @@ -29,7 +29,7 @@ module: "ga4-event-tracker", ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 1, index_total: 1, section: 'Footer', diff --git a/app/views/content_items/hmrc_manual_section.html.erb b/app/views/content_items/hmrc_manual_section.html.erb index 9542a0fa5..6f83fd0d3 100644 --- a/app/views/content_items/hmrc_manual_section.html.erb +++ b/app/views/content_items/hmrc_manual_section.html.erb @@ -50,7 +50,7 @@ module: "ga4-event-tracker", ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 1, index_total: 1, section: 'Footer', diff --git a/app/views/content_items/html_publication.html.erb b/app/views/content_items/html_publication.html.erb index f2a2275ad..bf88e8aa7 100644 --- a/app/views/content_items/html_publication.html.erb +++ b/app/views/content_items/html_publication.html.erb @@ -62,10 +62,10 @@ module: "ga4-event-tracker", ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 1, index_total: 1, - section: 'Contents', + section: 'Content', }, }, } %> diff --git a/app/views/content_items/manual.html.erb b/app/views/content_items/manual.html.erb index e350d7912..03d93db86 100644 --- a/app/views/content_items/manual.html.erb +++ b/app/views/content_items/manual.html.erb @@ -38,7 +38,7 @@ module: "ga4-event-tracker", ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 1, index_total: 1, section: 'Footer', diff --git a/app/views/content_items/manual_section.html.erb b/app/views/content_items/manual_section.html.erb index fc047fe1c..bc9a416e5 100644 --- a/app/views/content_items/manual_section.html.erb +++ b/app/views/content_items/manual_section.html.erb @@ -94,7 +94,7 @@ module: "ga4-event-tracker", ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 1, index_total: 1, section: 'Footer', diff --git a/app/views/content_items/manuals/_updates.html.erb b/app/views/content_items/manuals/_updates.html.erb index 56893889c..c24f1e928 100644 --- a/app/views/content_items/manuals/_updates.html.erb +++ b/app/views/content_items/manuals/_updates.html.erb @@ -64,7 +64,7 @@ module: "ga4-event-tracker", ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 1, index_total: 1, section: 'Footer', diff --git a/app/views/content_items/travel_advice.html+print.erb b/app/views/content_items/travel_advice.html+print.erb index 370e726ff..8d5c50be7 100644 --- a/app/views/content_items/travel_advice.html+print.erb +++ b/app/views/content_items/travel_advice.html+print.erb @@ -26,10 +26,10 @@ "track-label": t("components.print_link.text"), ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 1, index_total: 2, - section: 'Contents', + section: 'Content', }, }, margin_bottom: 8, @@ -58,7 +58,7 @@ "track-label": t("components.print_link.text"), ga4_event: { event_name: 'print_page', - type: 'Print this page', + type: 'print page', index: 2, index_total: 2, section: 'Footer',