diff --git a/app/helpers/content_items_helper.rb b/app/helpers/content_items_helper.rb index 8a3d4c2c8..421be9c16 100644 --- a/app/helpers/content_items_helper.rb +++ b/app/helpers/content_items_helper.rb @@ -1,11 +1,11 @@ module ContentItemsHelper - def email_subscription_success_banner_heading(account_flash) + def email_subscription_success_banner_heading(account_flash, locale = nil) if account_flash.include?("email-subscription-success") - sanitize(t("email.subscribe_title")) + sanitize(t("email.subscribe_title", locale:)) elsif account_flash.include?("email-unsubscribe-success") - sanitize(t("email.unsubscribe_title")) + sanitize(t("email.unsubscribe_title", locale:)) elsif account_flash.include?("email-subscription-already-subscribed") - sanitize(t("email.already_subscribed_title")) + sanitize(t("email.already_subscribed_title", locale:)) end end diff --git a/app/views/content_items/call_for_evidence.html.erb b/app/views/content_items/call_for_evidence.html.erb index 944b6caee..7e2a8a969 100644 --- a/app/views/content_items/call_for_evidence.html.erb +++ b/app/views/content_items/call_for_evidence.html.erb @@ -4,7 +4,7 @@ ) %> <% end %> -<%= render 'shared/email_subscribe_unsubscribe_flash' %> +<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.title_and_context[:title] } %>
diff --git a/app/views/content_items/consultation.html.erb b/app/views/content_items/consultation.html.erb index 5ee1eaa01..473d0e7da 100644 --- a/app/views/content_items/consultation.html.erb +++ b/app/views/content_items/consultation.html.erb @@ -4,7 +4,7 @@ ) %> <% end %> -<%= render 'shared/email_subscribe_unsubscribe_flash' %> +<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.title_and_context[:title] } %>
diff --git a/app/views/content_items/detailed_guide.html.erb b/app/views/content_items/detailed_guide.html.erb index bb2ecaba9..8bf1709b5 100644 --- a/app/views/content_items/detailed_guide.html.erb +++ b/app/views/content_items/detailed_guide.html.erb @@ -55,7 +55,7 @@ <% end %> <% end %> -<%= render 'shared/email_subscribe_unsubscribe_flash' %> +<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.title_and_context[:title] } %>
diff --git a/app/views/content_items/publication.html.erb b/app/views/content_items/publication.html.erb index 77184b7a9..369dd5a9b 100644 --- a/app/views/content_items/publication.html.erb +++ b/app/views/content_items/publication.html.erb @@ -13,7 +13,7 @@ <% end %> <% end %> -<%= render 'shared/email_subscribe_unsubscribe_flash' %> +<%= render 'shared/email_subscribe_unsubscribe_flash', { title: @content_item.title } %>
diff --git a/app/views/shared/_email_subscribe_unsubscribe_flash.html.erb b/app/views/shared/_email_subscribe_unsubscribe_flash.html.erb index 3624ccff1..2d0b759e6 100644 --- a/app/views/shared/_email_subscribe_unsubscribe_flash.html.erb +++ b/app/views/shared/_email_subscribe_unsubscribe_flash.html.erb @@ -5,11 +5,27 @@ <% if show_email_subscription_success_banner?(@account_flash) %>
- <%= render "govuk_publishing_components/components/success_alert", { - message: email_subscription_success_banner_heading(@account_flash), - description: banner_description, - margin_bottom: 0, - } %> + <% + ga4_data = { + event_name: "form_complete", + type: "email subscription", + text: email_subscription_success_banner_heading(@account_flash, :en), + section: local_assigns[:title], + action: "complete", + tool_name: "Get emails from GOV.UK" + }.to_json + %> + <%= content_tag(:div, + data: { + module: "ga4-auto-tracker", + ga4_auto: ga4_data + }) do %> + <%= render "govuk_publishing_components/components/success_alert", { + message: email_subscription_success_banner_heading(@account_flash), + description: banner_description, + margin_bottom: 0, + } %> + <% end %>
<% end %>