Repository navigation
Send searches to Google Tag Manager for search analytics - #6
Merged
Merged
Conversation
This pull request updates the valkey website for the new release 9.2.1. Changes: - Updated downloads page with new release information - Updated Try Valkey page to use version 9.2.1 This pull request is created automatically by the [Valkey-Release-Automation](https://github.com/valkey-io/valkey-release-automation) --------- Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Signed-off-by: notleowang <leo.wang@improving.com>
Each search, from the header and from the search page, is pushed to Google Tag Manager's data layer as a "search" event once typing pauses: the query (search_term), how many results match it (search_results), and where it was searched (search_location, "modal" or "page"). Pagefind matches loosely, so even a made-up word returns a few results, scoring about 0.001, while real searches, typos included, score 2 or more. Only results scoring at least 0.1 are counted, so a search with search_results of 0 is a miss. The same query isn't counted twice in a row. Queries that look like an email address aren't sent, and queries are cut to 100 characters. valkey.io loads Google Analytics through the Linux Foundation's Tag Manager container, so the event reaches Analytics once a Custom Event trigger for "search" and a GA4 event tag are set up there, along with custom dimensions for search_results and search_location in GA4. Until then it isn't sent anywhere. Signed-off-by: notleowang <leo.wang@improving.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds search analytics for the review from @stockholmux on valkey-io#723, to be merged into
site-search. Follows #5, which added the search page.Every search, from the header and from the search page, is pushed to Google Tag Manager's data layer as a
searchevent once typing pauses:search_termsearch_results0for a misssearch_locationmodal(header) orpage(search page)0and typos still count as hits.GTM-MFFCB7SR), notgtag.js. Pushing an event to the data layer for Tag Manager to forward is the approach recommended for this setup, and it keeps the site's consent settings in charge of whether anything is recorded.Needed outside this repository
The event reaches GA4 once these are set up by whoever manages valkey.io's Tag Manager and GA4. Until then it isn't sent anywhere, so merging this doesn't change the current reports.
search, Data Layer Variables for the three fields, and a GA4 event tag sending them to the site's GA4 property.search_resultsandsearch_locationregistered as custom dimensions, so hits, misses and location appear in reports.The search page's
?q=URL can also be recorded by GA4's own site search tracking, if it's switched on in the property's enhanced measurement.Review items
Commits
This branch also includes
site-search's merge of upstreammain(632fcb9, with valkey-io#808, the 9.2.1 release update), which hasn't been pushed tosite-searchyet. The analytics change is 1268a22.Testing
Built locally (Zola 0.23.6, Pagefind 1.6.0) and checked in headless Chrome with all hosts but the local site blocked, so nothing was sent to Google:
/search/?q=migrationpushessearch_term: "migration",search_results: 65,search_location: "page".zzqxjv,qwxzvbn) pushsearch_results: 0. The typoreplicatonpushes4.search_location: "modal".{ event: 'search', … }object, as Tag Manager expects.build/check-search-index.pyreports 795 pages with 0 problems, and all 26 ranking cases pass.Check List
--signoff