Skip to content

Search term tracking (Phase 1) - #792

Closed
hazelngan wants to merge 2 commits into
TelosLabs:add-inkind-donationsfrom
hazelngan:search-term-tracking
Closed

Search term tracking (Phase 1)#792
hazelngan wants to merge 2 commits into
TelosLabs:add-inkind-donationsfrom
hazelngan:search-term-tracking

Conversation

@hazelngan

Copy link
Copy Markdown
Collaborator

I implemented Phase 1 of the search term tracking project! I can only test it after the code is committed and then check on Google Analytics to see if I can see the searches being logged. Let me know if that makes sense!

@jdelagarzaf

jdelagarzaf commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Hey Hazel! Nice work; just a few things we have to fix before you continue to the next phase.
Currently, the event never actually fires. This is because this app doesn't expose gtag globally, but rather is defined inside a turbo:load callback, meaning it only exists there and is inaccessible by your code. Instead, you could place your inline script inside a stimulus controller, which would guarantee it fires if switching the transport to window.dataLayer, it is safer without unescaped interpolation, and it refires on every search rather than on full page load. This simple fix would fix all three issues.

Besides that shift from inline script to Stimulus, there are two things to consider.
gtag in this app points to Google Ads, not Google Analytics. Instead, I would recommend pushing to the GTM datalayer, which is already loaded in the layout. To have it show in Google Analytics, we need to add a trigger and GA4 tag in the GTM console to forward the event, but that is configured outside the codebase, just worth knowing.
Additionally, change the action to fire on search submit rather than by reading params. This ensures the event fires only once per search rather than on every page reload or pagination, inflating the counts artificially.

Also, make sure the CI passes. Currently, your tests are failing, and your code has RuboCop issues. The branch git history is also contaminated; make sure you always base your new branches on main rather than your last worked item. For now, you could point this branch to the non-profit in-kind donation field branch via the PR settings to ensure the git history remains clean.

Remember that you may use Claude Code or any other AI agent to help you implement the changes if you need help.

@jdelagarzaf
jdelagarzaf changed the base branch from main to add-inkind-donations July 23, 2026 19:12
@jdelagarzaf

Copy link
Copy Markdown
Collaborator

Closed in favor of #800

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants