Skip to content

Commit

Permalink
Add GA4 form tracker to service manual search
Browse files Browse the repository at this point in the history
  • Loading branch information
AshGDS committed Nov 10, 2023
1 parent 05ff0af commit 544575e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/views/content_items/service_manual_homepage.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@
<p class="govuk-body-lead app-hero-lead app-hero__body--inverse govuk-!-padding-bottom-1">
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' %>.
</p>
<form action="/search" method="get" role="search">
<form
action="/search"
method="get"
role="search"
data-module="ga4-form-tracker"
data-ga4-form-include-text
data-ga4-form-no-answer-undefined
data-ga4-form='{"event_name": "search", "type": "content", "url": "/search/all", "section": "Service Manual", "action": "search"}' >
<input type="hidden" name="filter_manual" value="/service-manual">
<%= render "govuk_publishing_components/components/search", {
label_text: "Search the service manual",
Expand Down
9 changes: 9 additions & 0 deletions test/integration/service_manual_homepage_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 544575e

Please sign in to comment.