Follow me on LinkedIn - AI, GA4, BigQuery

What is Google Analytics 4 Site Search Tracking?

Through the GA4 site search tracking feature, you can determine the search terms used by your website visitors to find information on your website:

search terms used by your website visitors

What is the advantage of implementing site search tracking in GA4?

Once you have implemented site search tracking in your GA4 property, you can see the list of keywords (called ‘Search terms’) used by your website visitors to find information on your website:

you can see the list of keywords

This insight can help you in finding new content development opportunities and/or popular or trending products. 

Example-1:

Let us suppose you discovered that many website visitors are searching for the keyword ‘enhanced ecommerce tracking’ on your website.

Let us also suppose that your website does not have any article on ‘enhanced ecommerce tracking’.

In that case, you can publish a brand new article on ‘enhanced ecommerce tracking’, thus satisfying the website visitors’ query.

Example-2:

GA4 site search tracking can reveal popular or trending products on your e-commerce website.

Analysing search terms helps understand customer interests. High-searched items indicate strong demand. 

You should promote these products prominently on your website. Adjust marketing strategies based on search trends. 

This approach can enhance user experience and potentially increase website sales.

Requirements for setting up site search tracking in GA4

If you do not have a site search feature (aka the search box, the internal search engine) installed on your website, then you won’t be able to benefit from the site search tracking feature in GA4.

So, you need to have the site search feature on your website.

GA4 automatically tracks site searches (in most cases) once you have enabled Enhanced Measurement Tracking in your GA4 property:

GA4 automatically tracks site searches

The default site search tracking feature provided by GA4 may not always work for you.

There could be a situation in which the site search feature is installed on your website in such a way that the default site search tracking feature provided by GA4 won’t work for you.

In that case, you would need to use GTM (Google Tag Manager) to set up site search tracking in your GA4 property.

For example,

If you have the site search feature installed on your website, but the search term does not appear in the query parameter, then you won’t be able to benefit from the default site search tracking capability of GA4.

Here is what I meant by the search term appearing in the query parameter:

the search term appearing in the query parameter

Here, the query parameter is the part of the URL which comes after the ‘?’ character.

So the query parameter is:

s=utm+parameters

Following is the search term used in the query parameter:

utm+parameters

If you have the site search feature installed on your website, but the search term does not appear in the query string, then you would have to use GTM to set up site search tracking on your website.

Alternatively, 

You can ask your web developer to configure the URLs of search result pages in such a way that it shows the search terms in the query string.

How does the site search tracking work in GA4?

By default, GA4 fires the ‘view_search_results’ event when a user inputs a query and clicks on the search button on your website.

As the event gets fired on the website, Google sends a few default event parameters, such as search_term, page_location, and source

You can see these parameters in real-time in the GA4 Realtime report.

How to set up site search tracking in GA4?

Follow the steps below:

Step-1: Navigate to the website for which you want to set up site search tracking in GA4.

Step-2: Use the search feature of your website by entering a search term in the search box:

Use the search feature of your website

Step-3: Note down the search query parameter from the URL of the search result page:

Note down the search query parameter from the URL

Here ‘s’ is the search query parameter.

Step-4: Navigate to your GA4 Property.

Step-5: Click on the ‘Admin’ link available in the left-hand side reporting menu:

Click on the ‘Admin link

Step-6: Click on ‘Data Streams’ under ‘Data Collection and Modification‘:

Click on ‘Data Streams

Step-7: Click on the web data stream for which you want to set up site search tracking in GA4:

Click on the web data stream

Step-8: Make sure that the ‘Enhanced Measurement’ featured is enabled:

the ‘Enhanced Measurement featured is enabled

Step-9: Click on the gear button under ‘Enhanced measurement’ to access the settings menu:

Click on the gear button under ‘Enhanced measurement

Step-10: Make sure that the ‘Site Search’ feature is enabled:

the ‘Site Search feature is enabled

Step-11: Click on the link ‘Show advanced settings’ under the ‘Site search’:

‘Show advanced settings

You should now be able to see the advanced settings for the ‘site search’ feature:

see the advanced settings for the ‘site search feature

Though site search is automatically tracked in GA4, it will only work on default query parameters defined by Google: q,s,search,query,keyword.

only work on default query parameters defined by Google

If your website uses a search term query parameter which is not one of the default parameters supported by GA4, you would need to configure a custom parameter to fire the ‘view_search_results’ event.

For example, 

If your website uses the ‘st’ parameter in its URL to capture the search term:

https://www.optimizesmart.com/?st=utm+parameters

then you should enter the ‘st’ parameter in the text box below ‘Search Term Query Parameter’:

enter the ‘st parameter in the text

If you want to collect values from additional URL query parameters when the ‘view_search_results’ event occurs, then you should add the query parameters in the text box under ‘Additional Query Parameters’:

Additional Query Parameters

For example, 

The search URL below contains an additional query parameter called ‘title’:

https://www.optimizesmart.com/?st=utm+parameters&title=best+excel+charts

Now, if you want to collect values from the ‘title’ query parameter when the ‘view_search_results’ event occurs, then you should add the ‘title’ parameter in the text box under ‘Additional Query Parameters’:

add the ‘title parameter in the text

Additional query parameters are useful when your website search functionality allows users to filter search results using multiple filters.

Step-12: Click on the ‘Save’ button in the upper right corner of the overlay to save the advanced site search settings:

Click on the ‘Save button

Step-13: Click on ‘Custom definitions‘ under ‘Data Display‘ in the GA4 admin area:

Click on Custom definitions

Step-14: Click on the ‘Create custom dimension’ button:

Create custom dimension

Step-15: Enter ‘search_term’ as the dimension name:

Enter ‘search term as dimension name

Step-16: Type ‘search_term’ in the text box under the ‘Event parameter‘ and then click on the ‘Save’ button:

Type ‘search term in the text

You should now see the ‘search_term’ listed as a custom dimension:

see the ‘search term listed as a custom dimension

When you register an event parameter (like ‘search_term’) as a custom dimension and once the parameter is logged (i.e. recorded), you should see a new data card added to various event reports in GA4:

you should see a new data card added to various event reports in GA4

I will show you later how to view this data card.

How To Test Site Search Tracking in GA4

Once you have set up site search tracking in GA4, you need to test it to make sure that it is working correctly.

Follow the steps below to test site search tracking in GA4.

Step-1: Navigate to the website for which you set up site search tracking in GA4.

Step-2: Make sure that you have installed the Google Analytics Debugger’ Chrome extension in your web browser and that it is turned on:

installed the Google Analytics Debugger Chrome

Step-3: Use the search feature of your website by entering a search term in the search box:

Use the search feature of your website 2

You should now see the search result page:

see the search result page

Step-4: Click on the DebugView‘ link under ‘Data Display‘ in the GA4 admin area:

Click on the DebugView link under Data Display

Step-5: Set your debug device to ‘Google’ as we are using Google Analytics Debugger Chrome extension:

Set your debug device to ‘Google

Step-6: Wait for a minute or so, scroll down and then find and click on the event ‘view_search_results’:

find and click on the event ‘view search results

You should now see a screen like the one below:

view search results

Step-7: Scroll down and then click on the event parametersearch_term’:

click on the event parameter ‘search term
click on the event parameter ‘search term 2

You should now be able to see the keyword you used to find information on your website (in our case, the keyword is ‘utm parameters’):

see the keyword you used to find information on your website

Since you can see the ‘view_search_results’ event and its corresponding parameter, it means the site search tracking is working correctly on your website.

Once you have set up site search tracking in GA4 and tested it, you can create a site search tracking report in GA4.

There are two ways you can see the data related to site search terms in GA4:

#1 Through the ‘Events’ report.

#2 By creating an exploration report (recommended).

Finding site search terms data through the ‘Events’ report

Follow the steps below:

Step-1: Once you have set up site search tracking, wait for at least 24 hours before you go to find site search terms data in your GA4 property.

Step-2: Navigate to Reports > Engagement > Events.

events report ga4

Step-3: Type ‘search’ in the search box and then press the enter key:

Type ‘search in the search

Step-4: Click on the event name ‘view_search_results’:

Click event name ‘view search results

You should now see the report for the event ‘view_search_results’:

the report for the event ‘view search results

Step-5: Scroll down the report until you see the data card named ‘SEARCH_TERM’:

until you see the data card named ‘SEARCH TERM

This data card reports on the search terms in decreasing order of event count.

The data card has also got a scroll bar on the right to scroll down:

The data card has also got a scroll bar

Finding site search terms data via exploration report

Follow the steps below:

Step-1: Click on the ‘Explore’ link from the left-hand side navigation bar in your GA4 property:

Click on the ‘Explore link

Step-2: Click on the ‘Blank’ exploration report template:

Click on the ‘Blank exploration report template

Step-3: Name your report ‘Site Search Report’:

Site Search Report

Step-4: Set the date range to the last 30 days:

Set the date range to last 30 days

Step-5: Click on the + button next to ‘DIMENSIONS‘:

button next to ‘DIMENSIONS‘ 1

You will now see a screen like the one below:

select dimensions in exploration report

Step-6: Search for the ‘Search Term’ dimension and then click on the checkbox next to it:

Search for the ‘Search Term dimension

Step-7: Search for the ‘Event Name’ dimension and then click on the checkbox next to it:

Search for the ‘Event Name dimension

Step-8: Click on the ‘Import’ button to import all the selected dimensions to the report:

import all the selected dimensions to the report 1

You should now see all the imported dimensions listed under the DIMENSIONS section:

imported dimensions

Step-9: Click on the + button next to METRICS:

button next to METRICS 1

Step-10: Search and select the following metrics one by one in the exact order as mentioned below and then click on the ‘Import‘ button:

  1. event count
  2. event count per user
select the following metrics one by one

You should now see all the imported metrics listed under the METRICS section:

imported metrics

Step-11: Double-click on the dimension ‘Search Term’ so that it is automatically added to the Rows section:

Double click on the dimension ‘Search Term

Note: When you double-click on the ‘Search Term’ dimension, you won’t see any change to the canvas on the right. But the dimension has been added to the canvas. Only when you start adding metrics to the canvas will you start seeing the dimension(s) added to the canvas.

Step-12: Double-click on the following metrics one by one, starting from the very top, so that they are automatically added to the blank canvas on the right:

  1. event count.
  2. event count per user.
Double click on the following metrics one by one 1

Step-13: Scroll all the way down under the ‘Settings’ column until you see the section called ‘FILTERS’:

see the section called ‘FILTERS

Step-14: Click on ‘Drop or select dimension or metric’:

click on Drop or select dimension or metric

Step-15: Click on the ‘Event Name’ dimension from the drop-down menu:

Click on the ‘Event Name dimension

Step-16: Click on the ‘Select match type’ drop-down menu:

click on Select match type

Step-17: Click on ‘exactly matches’:

Click on ‘exactly matches

Step-18: Click on the ‘enter expression’ text box:

Click on the ‘enter expression text

You should now see a screen like the one below:

You should now see a screen like the one below 1

Step-19: Type ‘view_search’ in the text box and then click on the first search result:

Type ‘view search in the text

Step-20: Click on the ‘Apply’ button to apply your filter to the canvas on the right:

Click on the ‘Apply button to filter

You should now see a screen like the one below:

search term report ga4

That’s how you can see the site search terms data via the exploration report.

  1. Google Analytics 4 Channels, Source and Medium explained.
  2. Path exploration report in GA4 (Google Analytics 4) – Path analysis.
  3. How to use Microsoft Clarity with GA4 (Google Analytics 4).
  4. GA4 vs GA4 360 – Pricing, Limits, Billing and more.
  5. Setup Enhanced Conversions for Leads using Data Layer in Google Tag Manager.
  6. Self-referral Google Analytics 4 – Referral exclusion GA4.
  7. GA4 Attribution Paths (Conversion Paths) Report.
  8. Google Tag Manager Tutorial.
  9. GA4 Attribution Models Explained: How to Choose the Right One.
  10. Looker Studio (Google Data Studio) Tutorial.
  11. Google Tag Manager Data Layer Tutorial with Examples.
  12. Set up enhanced conversions for Web using ‘Code’ in Google Tag Manager.
  13. How to create Google Ads report in Google Analytics 4.
  14. Google Tag Manager Audit Checklist.
  15. Tracking Site Search in Google Analytics 4.
  16. How to see Organic Search Keywords in Google Analytics 4.