
How to Track Internal Site Search in GA4
If your website has a search box, you're sitting on a goldmine of intent data. Every query typed into that box tells you exactly what a visitor wanted and, often, whether they found it. Google Analytics 4 can track internal site search automatically through Enhanced Measurement, or you can wire it up manually for full control. This guide covers both paths.
Why Internal Site Search Data Matters
Unlike a lot of analytics data, site search queries are unfiltered intent. A visitor typing "return policy" or "wireless keyboard under $50" is telling you precisely what they're looking for — no interpretation needed. Tracking this lets you:
- Find content gaps (searches that return zero or poor results).
- Improve navigation and internal linking around popular queries.
- Feed high-intent search terms into product or content roadmaps.
- Identify visitors close to converting so you can retarget them.
Option 1: Enable Automatic Tracking via Enhanced Measurement
GA4's Enhanced Measurement can detect site search automatically, as long as your search results page uses a recognizable query parameter in the URL (like ?q=, ?s=, ?search=, or ?query=).
- Go to Admin > Data Streams and select your web stream.
- Click Enhanced measurement and open the gear icon next to it.
- Toggle on Site search.
- Review the query parameters GA4 checks for — add your own if it's not in the default list (e.g.,
keyword,term).
Once enabled, GA4 automatically fires a view_search_results event whenever it detects one of those parameters in the URL, with the query string captured as the search_term parameter.
Option 2: Track Site Search Manually
If your search doesn't reload the page (a common pattern with instant/AJAX search widgets), Enhanced Measurement won't catch it, since there's no new URL to inspect. You'll need to fire the event yourself.
function trackSiteSearch(query, resultsCount) {
gtag("event", "view_search_results", {
search_term: query,
results_count: resultsCount,
});
}
document.querySelector("#site-search-form").addEventListener("submit", (e) => {
const query = document.querySelector("#site-search-input").value;
const results = document.querySelectorAll(".search-result-item").length;
trackSiteSearch(query, results);
});
search_term is the parameter GA4 expects for this event, so keep that name exactly as-is if you want it to show up correctly in the built-in search terms report.
Setting It Up in Google Tag Manager
If you manage tags through GTM instead of hard-coding gtag calls, the setup looks like this:
- Create a Custom Event trigger that fires on your search form's submit event (or a
dataLayerpush, if your dev team pushes one on search). - Create a GA4 Event tag named
view_search_results. - Add an event parameter: key
search_term, value pulled from a Data Layer Variable or a DOM element variable reading the input's value. - Attach the trigger you created in step 1.
A matching dataLayer.push from your codebase would look like this:
document.querySelector("#site-search-form").addEventListener("submit", () => {
window.dataLayer.push({
event: "site_search",
search_term: document.querySelector("#site-search-input").value,
});
});
Combining Site Search with Other Signals
Search terms become far more useful once you connect them to what happened afterward. Two combinations are worth building as saved explorations:
- Search term → subsequent page view. Add
search_termas a row dimension and the nextpage_view's page path as a second dimension to see whether a search actually led somewhere useful, or whether the visitor bounced immediately after searching. - Search term → conversion. If you've marked a conversion event like
purchaseorgenerate_lead, cross-reference it againstsearch_termto find which queries most reliably lead to revenue. These are strong candidates for merchandising higher in your navigation or featuring in on-site promotions.
gtag("event", "view_search_results", {
search_term: query,
results_count: resultsCount,
search_type: "product", // helps distinguish product search from blog/help search
});
Adding a search_type parameter like this is useful the moment your site has more than one search box — for example, a product catalog search and a help-center search living on the same domain. Without it, both get lumped into the same search_term list and lose most of their usefulness.
Building a Weekly Search Terms Report
Rather than checking this ad hoc, it's worth setting up a recurring view:
- Build a free-form exploration with
search_termas the row dimension and event count plusresults_countas metrics. - Sort descending by event count to see your most common queries.
- Add a secondary breakdown by week if you want to track how demand shifts over time (useful for seasonal businesses).
- Save the exploration so it's a one-click check rather than a rebuild every time.
Reviewing this weekly alongside your zero-result list turns site search from a passive feature into an active source of product and content ideas.
Where to Find the Data
Once events are flowing, you have two main options for viewing them:
- Reports > Engagement > Events, filtered to
view_search_results, gives you a raw count over time. - A custom Explore report with
search_termas a dimension and event count as the metric gives you the actual list of queries, ranked by frequency.
You can also add search_term as a secondary dimension in the Pages and screens report to see which landing pages people search from most.
Tracking Zero-Result Searches
The most actionable data point is often searches that return nothing. Pass a results_count parameter (as shown above) and build an exploration filtered to results_count = 0 to surface content gaps directly.
gtag("event", "view_search_results", {
search_term: query,
results_count: 0,
no_results: true,
});
Reviewing this list weekly is one of the highest-leverage habits a content or SEO team can build.
FAQ about How to Track Internal Site Search in GA4

Does GA4 track site search by default?
No, but Enhanced Measurement can detect it automatically if your search results page uses a common query parameter and the toggle is turned on in your data stream settings.
What event name does GA4 use for site search?
view_search_results, with the query captured in the search_term parameter.
My search widget doesn't change the URL. Will Enhanced Measurement still work?
No — Enhanced Measurement relies on inspecting the URL query string, so single-page or AJAX-based search needs a manual gtag or GTM event.
Can I see which pages people search from most?
Yes, add search_term as a secondary dimension to the Pages and screens report, or build a free-form exploration combining page path and search term.
How do I find searches with no results?
Pass a results_count parameter with your search event, then filter or segment an exploration to results_count = 0.
Can I turn site search data into a conversion?
Yes — mark view_search_results as a conversion in Admin > Conversions if search usage itself is a meaningful engagement signal for your business.
Conclusion
Internal site search is one of the easiest wins in Google Analytics because it hands you visitor intent directly, with no guesswork. Whether you flip on Enhanced Measurement or wire up a manual event, the payoff is the same: a running list of exactly what your visitors are trying to find. Put that list in front of your content team and watch how quickly it shapes the roadmap — more examples of turning analytics into action live over on my site.


