Skip to content

Commit

Permalink
Add indexes to header search form
Browse files Browse the repository at this point in the history
- adds index_section and index_section count of 3 to the GA4 search form tracking data, to make it in line with other elements in these drop down menus
  • Loading branch information
andysellick committed Mar 28, 2024
1 parent d03c930 commit 3a1d80a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
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

0 comments on commit 3a1d80a

Please sign in to comment.