website
website copied to clipboard
Track Lunr search-result clicks
Tasks
- [x] Use
link_url
as parameter key instead ofvalue
; for details about click event parameters see [GA4] Analytics dimensions and metrics > Analytics dimensions > Links - #1571 - [x] Also set
outbound
tofalse
while we're at it - #1571 - [ ] Investigate other ways to identify search-result URL visits, such as using query parameter(s)
Context
Originally posted by @harshit-gangal in https://github.com/vitessio/website/pull/1519#discussion_r1304687307
The statement you are referring to (https://developers.google.com/tag-platform/devguides/events#gtag.js_1) concerns UA:
The Universal Analytics event information is structured as follows: <value> ... A non-negative integer that will appear as the vent value.
I'm not aware that this is a restriction for GA4. In fact, you can see the search-result URL from the realtime event reports page as the value of the value
attribute. For this example, I searched for "install" and clicked on the "Local Install via Homebrew" search result:
Also, by using the tagassistant, you can see that the search-result URL is available as ep.value
of a click
event:
Name | Parameter | Value |
---|---|---|
Protocol Version | v | 2 |
Measurement ID | tid | G-JWT03RNV4P |
Page Title | dt | Vitess | Scalable. Reliable. MySQL-compatible. Cloud-native. Database. |
Event Name | en | click |
Event Parameter | ep.anonymize_ip | false |
Event Parameter | ep.event_category | Lunr Search |
Event Parameter | ep.event_label | Search-result Click |
Event Parameter | ep.search_term | install |
Event Parameter | ep.value | https://vitess.io/docs/17.0/get-started/local-mac/ |
That being said, it will be difficult to use GA4 reports to view the URL. Let me investigate this further.
For a search-result click event, it would be better to use link_url
rather than value
to hold the search-result URL. Let me make that change first. Note that even with that change, I haven't been able to generate reports containing that URL, despite adding custom metrics. (Maybe it's just because custom reports don't have access to realtime data, so I'll try again tomorrow.)
Yesterday I defined some custom metrics (see below), but it seems that only restricted metric types are supported, excluding strings:
The custom metrics (set to type "standard") turn out to be interpreted as integers in reports: