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

Search tracking for manual pages #2942

Merged
merged 1 commit into from
Oct 3, 2023
Merged

Search tracking for manual pages #2942

merged 1 commit into from
Oct 3, 2023

Conversation

andysellick
Copy link
Contributor

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

What

Why

Part of the GA4 migration.

Visual changes

None.

Trello card: https://trello.com/c/zZGLn0tw/694-search-enhancement-add-search-form-tracking-to-manual-manualsection-and-hmrcmanualsection-pages

@andysellick andysellick requested a review from AshGDS October 3, 2023 08:23
@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2942 October 3, 2023 08:23 Inactive
Copy link
Contributor

@AshGDS AshGDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, though I think these need to be investigated 👍

@@ -31,10 +29,8 @@
<%= render 'govuk_publishing_components/components/metadata', metadata_with_ga4_tracking %>

<div class="in-manual-search">
<form action="/search/all" >

<form action="/search/all" data-module="ga4-form-tracker" data-ga4-form='{ "event_name": "search", "type": "content", "section": "<%= content_item.title %>", "action": "search" }'>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth using .to_json to build this, as if the content_item.title contains a double quote, it looks like the tracking breaks.

E.g.

<% test_title = "This has an \" escaped quote in it"%>
      <form action="/search/all" data-module="ga4-form-tracker" data-ga4-form='{ "event_name": "search", "type": "content", "section": "<%= test_title %>", "action": "search" }'>
        <input type='hidden' name="manual[]" value="<%= content_item.base_path %>">

Returns this on submit

GA4 configuration error: Expected ',' or '}' after property value in JSON at position 71 (line 1 column 72) Location {ancestorOrigins: DOMStringList, href: 'http://127.0.0.1:3090/hmrc-internal-manuals/compliance-handbook/ch160200', origin: 'http://127.0.0.1:3090', protocol: 'http:', host: '127.0.0.1:3090', …}

Also, the search term is coming through as [redacted] - is that correct?

Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout, thanks for spotting that, have reworked.

Going to go back to the PAs on the search term - you're probably right, we should should capture it but process it for PII.

@govuk-ci govuk-ci temporarily deployed to government-frontend-pr-2942 October 3, 2023 12:09 Inactive
@andysellick andysellick merged commit 8979f9a into main Oct 3, 2023
6 checks passed
@andysellick andysellick deleted the ga4-search-tracking branch October 3, 2023 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants