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

  1. Go to your website and perform a search
  2. 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

  1. Go to https://analytics.google.com
  2. Select your GA4 property
  3. Click Admin > Data Streams > Web
  4. Under Enhanced Measurement, click the gear icon (Configure Tag Settings)
  5. Click the arrow next to Site Search
  6. Enter your query parameter(s) (e.g., q,search,s)
  7. 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_location to 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:

  1. Use Google Tag Manager
  2. Create a Custom Event Trigger when a search occurs
  3. Create a GA4 Event Tag with:
    • Event Name: view_search_results
    • Parameter: search_term: {{Search Term Variable}}
  4. Set the trigger based on form submission, JavaScript event, or DOM changes
  5. 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