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 GA4 indexes to header search form #3966

Merged
merged 1 commit into from
Apr 8, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,22 @@
</h3>
<div class="govuk-grid-row">
<div class="govuk-grid-column-full">
<%
form_attributes = {
event_name: "search",
type: "header menu bar",
section: "Search GOV.UK",
action: "search",
url: "/search/all",
index_section: 3,
index_section_count: 3,
}.to_json
%>
<form
class="gem-c-layout-super-navigation-header__search-form"
id="search"
data-module="ga4-form-tracker"
data-ga4-form='{ "event_name": "search", "type": "header menu bar", "section": "Search GOV.UK", "action": "search", "url": "/search/all" }'
data-ga4-form="<%= form_attributes %>"
data-ga4-form-include-text
data-ga4-form-no-answer-undefined
action="<%= absolute_links_helper.make_url_absolute('/search') %>"
Expand Down
10 changes: 10 additions & 0 deletions spec/components/layout_super_navigation_header_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,15 @@ def component_name
assert_select 'a[data-ga4-link=\'{"event_name":"navigation","type":"header menu bar","index_section":1,"index_link":16,"index_section_count":3,"index_total":16,"section":"Services and information"}\']'
assert_select 'a[data-ga4-link=\'{"event_name":"navigation","type":"header menu bar","index_section":2,"index_link":1,"index_section_count":3,"index_total":6,"section":"Government activity"}\']'
assert_select 'a[data-ga4-link=\'{"event_name":"navigation","type":"header menu bar","index_section":2,"index_link":6,"index_section_count":3,"index_total":6,"section":"Government activity"}\']'
form_attributes = {
event_name: "search",
type: "header menu bar",
section: "Search GOV.UK",
action: "search",
url: "/search/all",
index_section: 3,
index_section_count: 3,
}.to_json
assert_select "form[data-ga4-form=\'#{form_attributes}\']"
end
end