From 544575e766418bcc1e1042811a3544780431a3ed Mon Sep 17 00:00:00 2001 From: AshGDS <8880610+AshGDS@users.noreply.github.com> Date: Fri, 10 Nov 2023 11:19:16 +0000 Subject: [PATCH] Add GA4 form tracker to service manual search --- app/views/content_items/service_manual_homepage.html.erb | 9 ++++++++- test/integration/service_manual_homepage_test.rb | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/views/content_items/service_manual_homepage.html.erb b/app/views/content_items/service_manual_homepage.html.erb index a2cc0f035..3b635e6cc 100644 --- a/app/views/content_items/service_manual_homepage.html.erb +++ b/app/views/content_items/service_manual_homepage.html.erb @@ -20,7 +20,14 @@

Helping teams to create and run great public services that meet the <%= link_to 'Service Standard', '/service-manual/service-standard', class: 'govuk-link govuk-link--inverse' %>.

-
+ <%= render "govuk_publishing_components/components/search", { label_text: "Search the service manual", diff --git a/test/integration/service_manual_homepage_test.rb b/test/integration/service_manual_homepage_test.rb index f464aed01..b17e0e66e 100644 --- a/test/integration/service_manual_homepage_test.rb +++ b/test/integration/service_manual_homepage_test.rb @@ -50,4 +50,13 @@ class ServiceManualHomepageTest < ActionDispatch::IntegrationTest assert page.has_link? "communities of practice", href: "/service-manual/communities" end + + test "the homepage includes GA4 form tracking on the search form" do + setup_and_visit_content_item("service_manual_homepage") + + assert page.has_selector?("[data-module='ga4-form-tracker']") + assert page.has_selector?("[data-ga4-form='{\"event_name\": \"search\", \"type\": \"content\", \"url\": \"/search/all\", \"section\": \"Service Manual\", \"action\": \"search\"}']") + assert page.has_selector?("[data-ga4-form-include-text]") + assert page.has_selector?("[data-ga4-form-no-answer-undefined]") + end end