Track search dropdown usage in Google Analytics
What does this MR do and why?
Adds Google Analytics tracking for search form usage.
See https://gitlab.com/gitlab-org/technical-writing/docs-gitlab-com/-/issues/461.
Screenshots, screen recordings, or links to review app
GA event firing when a query is entered:
New markup for tracking dropdown clicks:
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Configure a local GitLab Docs environment.
- Check out this branch.
- Run the site with analytics enabled:
ANALYTICS_ENABLED=true make view - In the console, enter
window.dataLayerto view the GA dataLayer object. - Run a search and print
window.dataLayeragain. Note that the search has registered as an event. - Inspect HTML on the dropdown; you'll see a new
data-ga-section="search dropdown"attribute on the result panel. - On the review app (where analytics are not enabled), verify you can run a search without any errors in the console.
Merge request acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this merge request.

