From a54e77ad3ce6d21b963a67902f534e031fec2a56 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Wed, 29 Nov 2023 09:36:12 +0000 Subject: [PATCH] Set expander GA4 data attrs outside component - credit to @floehopper - decouples the component from this app without losing any of the existing GA4 tracking --- app/views/components/_date_filter.html.erb | 2 +- app/views/components/_expander.html.erb | 1 - app/views/finders/_taxon_facet.html.erb | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/components/_date_filter.html.erb b/app/views/components/_date_filter.html.erb index 3e8ac00e9f..bb92e7ae62 100644 --- a/app/views/components/_date_filter.html.erb +++ b/app/views/components/_date_filter.html.erb @@ -8,7 +8,7 @@ date_errors_to ||= nil %> <% if key && name %> - <%= render "components/expander", { title: name } do %> + <%= render "components/expander", { title: name, data_attributes: { "ga4-filter-parent": name } } do %>
<%= render "govuk_publishing_components/components/input", { label: { diff --git a/app/views/components/_expander.html.erb b/app/views/components/_expander.html.erb index d142d39b06..81f72a2417 100644 --- a/app/views/components/_expander.html.erb +++ b/app/views/components/_expander.html.erb @@ -10,7 +10,6 @@ component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns) component_helper.add_data_attribute({ module: "expander" }) component_helper.add_data_attribute({ "open-on-load": open_on_load }) - component_helper.add_data_attribute({ "ga4-filter-parent": title }) component_helper.add_class("app-c-expander") component_helper.add_class(shared_helper.get_margin_bottom) unless margin_bottom == 0 %> diff --git a/app/views/finders/_taxon_facet.html.erb b/app/views/finders/_taxon_facet.html.erb index 1b3c6bab99..bf1d5d906a 100644 --- a/app/views/finders/_taxon_facet.html.erb +++ b/app/views/finders/_taxon_facet.html.erb @@ -1,6 +1,7 @@ <% unless i_am_a_topic_page_finder %> <%= render "components/expander", { - title: "Topic" + title: "Topic", + data_attributes: { "ga4-filter-parent": "Topic" } } do %>
<%= render "govuk_publishing_components/components/select", {