Question from Reddit user:
Hey everyone,
I’m trying to capture the exact search query from Google Ads and pass it as a UTM parameter to my website. The
{keyword}
placeholder only gives me the matched keyword, but not the actual phrase the user searched for.I’ve explored a few workarounds, but none seem to fully solve the issue:
{querystring}
doesn’t always work- Auto-tagging + GA4 provides the data in Analytics, but not in the URL
- Some ideas using Google Tag Manager & referrer URLs seem possible, but I’m not sure how to set them up properly
Has anyone successfully tracked the exact search phrase directly in a UTM parameter? Any insights or working methods would be greatly appreciated! 🙌
Thanks!
Answer from Nabil:
The short answer is:
You cannot reliably track the exact Google Ads search query directly as a UTM parameter in the final URL because Google deliberately does not provide a URL parameter placeholder for the search term, even though the data is technically recorded by Google.
Relying on client-side GTM workarounds is fragile and prone to failure due to browser limitations.
The most robust and scalable solution is to use a server-side process to join the exact search query data from the Google Ads API with the session data from your website, which is identified by the Google Click ID (gclid
), rather than trying to force the query into a UTM.
The long answer is:
Your frustration is completely understandable; this is a long-standing constraint that Google imposes for user privacy and data security.
You correctly noted that the only available parameter, {keyword}
, provides the matched keyword from your ad group, not the user’s actual search term.
Your observation that auto-tagging combined with GA4 provides the data in Google Analytics is the key to the solution, but it doesn’t solve the problem of getting the search query into the URL for other tools or for immediate client-side use.
The reason the {querystring}
parameter doesn’t consistently work is that it only passes through parameters that are already in your tracking template, and there is no Google-provided parameter to populate the exact user search query.
To achieve your goal of accessing this highly granular data outside of the Google Ads or GA4 interfaces, you need to implement a sophisticated, server-side data joining process.
This process uses the Google Ads API to extract the exact Search Query Report data, which includes the user’s search term and the corresponding Google Click ID (gclid
).
Separately, the Google Analytics Data API is used to extract session and conversion data, also tied to the same gclid
that was automatically captured by GA4 auto-tagging.
The solution involves using a server-side environment, such as a GTM server container hosted on a service like Stape or your own Google Cloud Platform.
You can use client-side Google Tag Manager to capture the gclid
and any other relevant session details and immediately send them to your server container.
While you won’t get the search query at this stage, the server container keeps a record of that session keyed by the gclid
.
Periodically, or on demand, a script on your server environment (or in a third-party tool) uses the Google Ads API to pull the Search Query Report data.
This data is then joined with your website session data using the common identifier: the gclid
.
Once the join is successful, you have a single, clean data set that links the user’s actual search query to the session, all the standard events like page_view
and user_engagement
, and the final conversion event like purchase
.
Finally, you can use the Looker Studio API to visualize this joined dataset in custom reports and dashboards, allowing you to filter and drill down by the exact search query, campaign, and conversion outcome, which fulfills your goal of seeing the deepest level of detail, without ever needing to pass the query through a fragile UTM parameter in the URL.