Skip to content

Commit

Permalink
Set expander GA4 data attrs outside component
Browse files Browse the repository at this point in the history
- credit to @floehopper
- decouples the component from this app without losing any of the existing GA4 tracking
  • Loading branch information
andysellick committed Nov 29, 2023
1 parent 5c908f1 commit a54e77a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/views/components/_date_filter.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<div class="govuk-!-margin-bottom-0" id="<%= key %>">
<%= render "govuk_publishing_components/components/input", {
label: {
Expand Down
1 change: 0 additions & 1 deletion app/views/components/_expander.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
%>
Expand Down
3 changes: 2 additions & 1 deletion app/views/finders/_taxon_facet.html.erb
Original file line number Diff line number Diff line change
@@ -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 %>
<div class="js-taxonomy-select" data-ga4-change-category="update-filter select" data-ga4-section="Topic">
<%= render "govuk_publishing_components/components/select", {
Expand Down

0 comments on commit a54e77a

Please sign in to comment.