-
Notifications
You must be signed in to change notification settings - Fork 17
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
Conversation
There was a problem hiding this 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" }'> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
- adds GA4 tracking to search forms on manual pages - including manuals e.g. https://www.gov.uk/guidance/understanding-your-driving-test-result/car-driving-test - and manual section e.g. https://www.gov.uk/guidance/understanding-your-driving-test-result/car-driving-test - and hmrc manual e.g. https://www.gov.uk/hmrc-internal-manuals/capital-gains-manual
48a9d4e
to
22ffe71
Compare
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