vitessio / website

vitess.io website and other project management related content
https://vitess.io
Apache License 2.0
48 stars 187 forks source link

Track Lunr search-result clicks #1570

Open chalin opened 10 months ago

chalin commented 10 months ago

Tasks

Context

_Originally posted by @harshit-gangal in https://github.com/vitessio/website/pull/1519#discussion_r1304687307_

image

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: \ ... 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:

Screen Shot 2023-08-28 at 14 38 15

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.

chalin commented 10 months ago

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.)

chalin commented 10 months ago

Yesterday I defined some custom metrics (see below), but it seems that only restricted metric types are supported, excluding strings:

Screen Shot 2023-08-29 at 18 15 35

The custom metrics (set to type "standard") turn out to be interpreted as integers in reports:

image