diff --git a/app/controllers/subscriptions_management_controller.rb b/app/controllers/subscriptions_management_controller.rb index 2b5b698e..475549aa 100644 --- a/app/controllers/subscriptions_management_controller.rb +++ b/app/controllers/subscriptions_management_controller.rb @@ -84,6 +84,7 @@ def confirmed_unsubscribe_all flash[:success] = { message: t("subscriptions_management.confirmed_unsubscribe_all.success_message"), description: t("subscriptions_management.confirmed_unsubscribe_all.success_description"), + description_en: t("subscriptions_management.confirmed_unsubscribe_all.success_description", locale: :en), } rescue GdsApi::HTTPNotFound # The user has already unsubscribed. diff --git a/app/views/subscriptions_management/confirm_unsubscribe_all.html.erb b/app/views/subscriptions_management/confirm_unsubscribe_all.html.erb index 2ac45123..68ade5cb 100644 --- a/app/views/subscriptions_management/confirm_unsubscribe_all.html.erb +++ b/app/views/subscriptions_management/confirm_unsubscribe_all.html.erb @@ -15,7 +15,21 @@
<%= t("subscriptions_management.confirm_unsubscribe_all.description") %>
-<%= form_tag(action: :confirmed_unsubscribe_all) do %> +<% + ga4_data = { + event_name: "form_response", + type: "email subscription", + section: t("subscriptions_management.confirm_unsubscribe_all.heading", locale: :en), + action: "unsubscribe", + tool_name: "Get emails from GOV.UK" + }.to_json +%> +<%= form_tag( + { action: :confirmed_unsubscribe_all }, + data: { + module: "ga4-form-tracker", + ga4_form: ga4_data + }) do %> <%= hidden_field_tag(:from, @from) %> <%= render 'govuk_publishing_components/components/button', { text: 'Unsubscribe', diff --git a/app/views/subscriptions_management/index.html.erb b/app/views/subscriptions_management/index.html.erb index 47d48eb4..7b40ef75 100644 --- a/app/views/subscriptions_management/index.html.erb +++ b/app/views/subscriptions_management/index.html.erb @@ -1,10 +1,26 @@ <% content_for :title, t("subscriptions_management.heading") %> <% if flash[:success] %> - <%= render 'govuk_publishing_components/components/success_alert', { - message: flash[:success]["message"], - description: flash[:success]["description"], - } %> + <% + ga4_data = { + event_name: "form_complete", + type: "email subscription", + text: flash[:success]["description_en"], + section: t("subscriptions_management.heading", locale: :en), + 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: flash[:success]["message"], + description: flash[:success]["description"], + } %> + <% end %> <% end %> <% if flash[:subscription] %> @@ -12,7 +28,7 @@ <% if subscription %> <% ga4_data = { - event_name: "form_response", + event_name: "form_complete", type: "email subscription", text: t("subscriptions_management.index.flashes.subscription", title: subscription["subscriber_list"]["title"], locale: :en), section: t("subscriptions_management.heading", locale: :en), diff --git a/app/views/subscriptions_management/update_frequency.html.erb b/app/views/subscriptions_management/update_frequency.html.erb index 52da69bc..aae193d5 100644 --- a/app/views/subscriptions_management/update_frequency.html.erb +++ b/app/views/subscriptions_management/update_frequency.html.erb @@ -14,7 +14,22 @@ margin_bottom: 6, } %> -<%= form_tag change_frequency_path, method: :post do %> +<% + ga4_data = { + event_name: "form_response", + type: "email subscription", + section: t("subscriptions_management.update_frequency.title", subscription_title: get_subscription_title(@subscriptions[@subscription_id]), locale: :en), + action: "save", + tool_name: "Get emails from GOV.UK" + } +%> +<%= form_tag( + change_frequency_path, + method: :post, + data: { + module: "ga4-form-tracker", + ga4_form: ga4_data + }) do %> <%= hidden_field_tag :id, @subscription_id %> <%= render 'govuk_publishing_components/components/radio', { name: 'new_frequency',