Skip to content

Commit

Permalink
Flatten GA4 attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
andysellick committed Oct 30, 2023
1 parent 44300c5 commit 03169f2
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 48 deletions.
4 changes: 1 addition & 3 deletions app/views/content_items/detailed_guide.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@
ga4_event: {
event_name: 'print_page',
type: 'print page',
index: {
index_link: 1,
},
index_link: 1,
index_total: 2,
section: 'Content',
},
Expand Down
8 changes: 2 additions & 6 deletions app/views/content_items/guide.html+print.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
ga4_event: {
event_name: 'print_page',
type: 'print page',
index: {
index_link: 1,
},
index_link: 1,
index_total: 2,
section: 'Content',
},
Expand Down Expand Up @@ -62,9 +60,7 @@
ga4_event: {
event_name: 'print_page',
type: 'print page',
index: {
index_link: 2,
},
index_link: 2,
index_total: 2,
section: 'Footer',
},
Expand Down
4 changes: 1 addition & 3 deletions app/views/content_items/html_publication.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@
ga4_event: {
event_name: 'print_page',
type: 'print page',
index: {
index_link: 1,
},
index_link: 1,
index_total: 1,
section: 'Content',
},
Expand Down
6 changes: 2 additions & 4 deletions app/views/content_items/manuals/_manual_layout.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@
ga4_event: {
event_name: 'print_page',
type: 'print page',
index: {
index_link: 1,
},
index_link: 1,
index_total: 1,
section: 'Footer',
},
},
} %>
} %>
</div>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
ga4_event: {
event_name: 'print_page',
type: 'print page',
index: {
index_link: 1,
},
index_link: 1,
index_total: 1,
section: 'Footer',
},
Expand Down
4 changes: 1 addition & 3 deletions app/views/content_items/manuals/_updates.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@
ga4_event: {
event_name: 'print_page',
type: 'print page',
index: {
index_link: 1,
},
index_link: 1,
index_total: 1,
section: 'Footer',
},
Expand Down
8 changes: 2 additions & 6 deletions app/views/content_items/travel_advice.html+print.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
ga4_event: {
event_name: 'print_page',
type: 'print page',
index: {
index_link: 1,
},
index_link: 1,
index_total: 2,
section: 'Content',
},
Expand Down Expand Up @@ -62,9 +60,7 @@
ga4_event: {
event_name: 'print_page',
type: 'print page',
index: {
index_link: 2,
},
index_link: 2,
index_total: 2,
section: 'Footer',
},
Expand Down
12 changes: 6 additions & 6 deletions app/views/content_items/travel_advice.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
<%= render "govuk_publishing_components/components/govspeak", {
} do %>
<% @content_item.alert_status.each do |text| %>
<%= render "govuk_publishing_components/components/warning_text",
text: text
%>
<%= render "govuk_publishing_components/components/warning_text",
text: text
%>
<% end %>
<% end %>

<aside class="part-navigation-container" role="complementary">
<%= render "govuk_publishing_components/components/contents_list", aria: { label: t("travel_advice.pages") }, contents: @content_item.part_link_elements, underline_links: true, ga4_tracking: true %>

<div
<div
data-module="ga4-link-tracker"
data-ga4-link='{ "event_name": "navigation", "type": "subscribe", "index": { "index_link": 1 }, "index_total": 1, "section": "Top" }'
data-ga4-link='{ "event_name": "navigation", "type": "subscribe", "index_link": 1, "index_total": 1, "section": "Top" }'
data-ga4-track-links-only
>
<%= render 'govuk_publishing_components/components/subscription_links',
Expand All @@ -46,7 +46,7 @@
<% unless @content_item.parts.empty? %>
<div class="govuk-grid-column-two-thirds govuk-!-margin-top-6">
<%= render 'govuk_publishing_components/components/heading', heading_level: 1, font_size: 'l', margin_bottom: 6, text: @content_item.current_part_title %>

<% if @content_item.no_part_slug_provided? %>
<%= render 'shared/travel_advice_first_part', content_item: @content_item %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% if @content_item.taxonomy_topic_email_override_base_path.present? %>
<div
data-module="ga4-link-tracker"
data-ga4-link='{ "event_name": "navigation", "type": "subscribe", "index": { "index_link": 1 }, "index_total": 1, "section": "Top" }'
data-ga4-link='{ "event_name": "navigation", "type": "subscribe", "index_link": 1, "index_total": 1, "section": "Top" }'
data-ga4-track-links-only
>
<%= render "govuk_publishing_components/components/signup_link", {
Expand Down
6 changes: 3 additions & 3 deletions app/views/shared/_email_signup.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
id: "related-subscriptions",
} %>

<div
class="related-item__subscription-link"
<div
class="related-item__subscription-link"
data-module="ga4-link-tracker"
data-ga4-link='{ "event_name": "navigation", "type": "subscribe", "index": { "index_link": 1 }, "index_total": 1, "section": "Sidebar" }'
data-ga4-link='{ "event_name": "navigation", "type": "subscribe", "index_link": 1, "index_total": 1, "section": "Sidebar" }'
data-ga4-track-links-only
>
<%= render "govuk_publishing_components/components/subscription_links", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
ga4_link: {
event_name: "navigation",
type: "subscribe",
index: {
index_link: 2
},
index_link: 2,
index_total: 2,
section: "Footer"
}
Expand All @@ -36,9 +34,7 @@
ga4_event: {
event_name: 'print_page',
type: 'print page',
index: {
index_link: 2,
},
index_link: 2,
index_total: 2,
section: 'Footer',
},
Expand Down
4 changes: 1 addition & 3 deletions app/views/shared/_single_page_notification_button.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
ga4_link: {
event_name: "navigation",
type: "subscribe",
index: {
index_link: 1
},
index_link: 1,
index_total: 2,
section: "Top"
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def single_page_notification_button_ga_tracking(index_link, section)
{
"event_name" => "navigation",
"type" => "subscribe",
"index" => { "index_link" => index_link },
"index_link" => index_link,
"index_total" => 2,
"section" => section,
"url" => "/email/subscriptions/single-page/new",
Expand Down

0 comments on commit 03169f2

Please sign in to comment.