diff --git a/CHANGELOG.md b/CHANGELOG.md index e93d0755b9..9e0f9235d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ## Unreleased * Chart component accessibility improvements ([PR #4344](https://github.com/alphagov/govuk_publishing_components/pull/4344)) -* Add new custom analytics tracker for search ([PR #4354](https://github.com/alphagov/govuk_publishing_components/pull/4354))) +* Add new custom analytics tracker for search and use in layout super nav header ([PR #4354](https://github.com/alphagov/govuk_publishing_components/pull/4354)) ## 44.9.1 diff --git a/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb b/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb index 3042495d5e..a4dfae7a1e 100644 --- a/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb +++ b/app/views/govuk_publishing_components/components/_layout_super_navigation_header.html.erb @@ -303,18 +303,12 @@ class: "gem-c-layout-super-navigation-header__search-form", id: "search", data: { - module: "ga4-form-tracker", - ga4_form: { - event_name: "search", - type: "header menu bar", - section: "Search GOV.UK", - action: "search", - url: "/search/all", - index_section: 3, - index_section_count: 3, - }, - ga4_form_include_text: "", - ga4_form_no_answer_undefined: "", + module: "ga4-search-tracker", + ga4_search_type: "header menu bar", + ga4_search_url: "/search/all", + ga4_search_section: "Search GOV.UK", + ga4_search_index_section: 3, + ga4_search_index_section_count: 3, }, action: absolute_links_helper.make_url_absolute("/search/all"), method: "get", diff --git a/spec/components/layout_super_navigation_header_spec.rb b/spec/components/layout_super_navigation_header_spec.rb index b4701d1641..251ecfdb06 100644 --- a/spec/components/layout_super_navigation_header_spec.rb +++ b/spec/components/layout_super_navigation_header_spec.rb @@ -173,15 +173,6 @@ 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}\']" + assert_select "form[data-module='ga4-search-tracker']" end end