Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the GA4 form tracker to /service-manual search #2985

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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