feat(iot-hub): track hero dropdown search queries in dataLayer#532
Merged
Conversation
The IoT Hub hero search popup ran its own fetch/render path and never pushed an iot_hub_query event, so live dropdown queries were invisible to GTM/GA4 (only submitted searches landing on /iot-hub/search/ were tracked). Mirror trackQuery() from iot-hub-dynamic-search.ts in the hero popup: push once per distinct trimmed term after the fetch resolves, skipping empty terms. PROD-8434
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.
Summary
The IoT Hub hero search popup on
/iot-hub/runs its own fetch/render code path (IotHubHero.astro) and never pushed aniot_hub_queryevent to the GTMdataLayer. As a result, live dropdown queries — what users type directly on the home page hero — were invisible to GTM/GA4. Only submitted searches that land on/iot-hub/search/were tracked, viatrackQuery()iniot-hub-dynamic-search.ts.This mirrors that tracking in the hero popup so the dropdown counts as a search surface too.
Changes
trackQuery()in the hero popup'ssetupPopup, called from the fetch.thenonce results resolve:lastTrackedQuery)search_results_countuses the shown item count (incl.0for zero-result queries)search_surface: 'all',search_filters: '',search_sort: DEFAULT_IOT_HUB_SORT_IDRef: PROD-8434