How do I track internal site search in GA4?
Applies to: Google Analytics 4 (GA4)
Last updated: May 2025
Problem
You want to see what users are searching for on your website—such as product names, help topics, or blog content—to understand demand, improve UX, or optimize content strategy.
Solution
GA4 can automatically track internal search terms if your site uses a URL-based search (e.g., ?q=search+term). You just need to configure the site search term parameter in your data stream settings. If your site uses a different format or JavaScript-based search, you may need to implement custom tracking with Google Tag Manager (GTM).
Step-by-Step Guide for Standard URL-Based Search
Step 1: Determine Your Search Query Parameter
- Go to your website and perform a search
- Look at the URL—find the parameter that holds the search term
Examples:
?q=shoes?search=blue+shirt?s=analytics
In these cases, the parameter is q, search, or s.
Step 2: Configure GA4 to Recognize the Parameter
- Go to https://analytics.google.com
- Select your GA4 property
- Click Admin > Data Streams > Web
- Under Enhanced Measurement, click the gear icon (Configure Tag Settings)
- Click the arrow next to Site Search
- Enter your query parameter(s) (e.g.,
q,search,s) - Click Save
GA4 will now track internal site search terms using the event name view_search_results.
Step 3: View Site Search Data in Reports
- Go to Reports > Engagement > Events
- Find and click on the event
view_search_results - Use dimensions like:
search_term(automatically captured parameter)page_locationto see where searches happened
You can also use Explorations to build more detailed reports by user segment or device.
Custom Setup (if your search doesn’t use a URL query parameter)
If your site uses a JavaScript-based search or doesn’t expose terms in the URL:
- Use Google Tag Manager
- Create a Custom Event Trigger when a search occurs
- Create a GA4 Event Tag with:
- Event Name:
view_search_results - Parameter:
search_term:{{Search Term Variable}}
- Event Name:
- Set the trigger based on form submission, JavaScript event, or DOM changes
- Save and publish
Notes
- GA4 does not track search results count by default (you can send it as a custom parameter)
- Site search helps improve navigation, reduce bounce rate, and surface content gaps
- You can build audiences based on specific search terms or frequent searchers





