×

How to Track Site Search in GA4 (Google Analytics 4)

Usman Qureshi

Last Modified on July 8, 2024

In today’s digital world, more and more quantitative and qualitative tools are coming to the front to help us understand what people are doing on our website and why they are doing so.

Thankfully, for us marketers, Google Analytics 4 also has one such feature which is being carried forward from UA, that can help us understand what people are trying to find on our website, i.e. the site search.

GA4 For Beginners

Master the basics with our FREE GA4 Course for Beginners

Even so, it is often not utilized to the maximum of its ability for us to understand user behavior. In this post, we will go over several topics to help you learn all about tracking site search in GA4.

Here’s what you would have learned by the end of this blog:

On the other hand, here’s a detailed overview of GA4’s DebugView, another great addition to GA4’s arsenal of features. Now, let’s start learning about GA4 site search tracking. 

What is the Importance of Site Search Tracking?

Your website’s internal site searches can tell you a lot about your site’s visitors, their intent, what they are looking for, and what is or is not available on the website.

Understand what Visitors are Looking for

Whether you have a blog or an eCommerce website, understanding what users are looking for on your website will help you to provide them with the type of content or product they are looking for, as well as optimize your website.

Your visitors can come from paid ads, an organic Google search, or any other source, but the search terms they use on your website can tell you:

  1. Their intent 
  2. Whether you have what they are looking for or not
  3. How the visitors describe your products/content

For instance, a visitor sees an ad for mobile phone accessories and lands on your website.

You can get a good idea about the visitor’s intent based on their source. Taking our example, we can see that they came from a search engine after actively searching for a product, which means they have a high intent of buying it.

However, they still might want to find a specific color phone case for an exact type of model/variant using certain keywords, which will reveal whether you have that product or not and how they describe them in their own language.

Optimize Your Website and UX

Looking at those terms will help you to ensure that visitors can find what they are looking for and that the content/products are relevant to them for a good experience.

Another way to gain trust and improve relevance for your visitors is using their own words on your website, which you can find through the search terms in GA4.

You can also find out if certain keywords are being searched more than others and create more of that content or stock those products, so your visitors don’t go to other websites.

All of this optimization and improvement in user experience is possible if you’re tracking site search terms and analyzing them.

Now that you understand why it is important to track internal search terms, let’s move on to see how we can set it up in GA4.

How to Implement Site Search in GA4?

This is where things might get a little tricky even though GA4 has made it easier to track the search terms. 

By default, site search in GA4 is being tracked if you haven’t turned off the enhanced measurement

Let’s find out where you can find site search settings in Google Analytics, understand what they mean, and configure them for your website.

1. Go to AdminData Streams and select the stream for which you want to set up a site search in GA4.

2. Next, click on the gear icon to view the site search settings.

Enhanced measurement settings under Data streams settings to view Site search in GA4

3. In the Site search configuration, click on Show advanced settings and you will see two fields for query parameters.

Site search toggled on and advanced settings showing Search Term Query Parameter and Additional Query Parameter fields under Enhanced measurement settings

First, what does Search Term Query Parameter mean? You can see that by default, Google has included the following query parameters here:

  • q
  • s
  • search
  • query
  • keyword

It means that whenever a website visitor performs a search, Google will trigger the view_search_results event as long as the above-mentioned query parameters are present in the URL. Also, note that only the first matching parameter will be used.

For instance, if we search for Google Analytics 4 on MeasureSchool’s website, the URL looks like this:

Showing query parameter “s” in URL on MeasureSchool’s site search

As you can see the letter “s” is present as a query parameter which will automatically trigger the view_search_results event in GA4 and send the search term with the event parameters.

The same event will automatically trigger if other query parameters like q, search, query, or keyword are present in the URL.

To clarify, the query parameter is anything that comes after the question mark “?” symbol in the URL.

What if the query parameter on your site’s URL does not match the default terms, like the following hair dryer search results URL? 

Different search term query parameter than what’s available by default in GA4 site search settings

4. Add the query parameter with a comma in Search Term Query Parameter (max up to 10 parameters are allowed).

Added searchTerm as query parameter that popped up in our search for hair dryer in the above example

Now you have your GA4 site search set up, but what if there are advanced filters or any other parameters for which you want to track the search terms?

GA4 has a solution for that, as well. Remember seeing the Additional query parameters box above – the one we can use to let Google know that we want to track these parameters as well.

For instance, you want to track the ‘section’ parameter in the below search results URL. 

Additional query parameter of section in the search results URL apart from searchTerm

All you have to do is put in ‘section’ in the Additional Query Parameters box. You can add a maximum of 10 additional parameters.

Adding section as an additional query parameter under the site search settings of enhanced measurement

Once done, save the settings and you will have correctly configured your site search tracking in GA4.

Don’t worry about the upper or lower case when adding the query parameters in the settings, as they are case-insensitive.

There are scenarios where GA4’s built-in functionality might not help, for instance, when there are no query parameters in the URL, auto-complete search, and so on.

This is where GTM kicks in and you can use several methods to send your site search terms to GA4 or even get a developer’s help, but that’s a topic for another day.

Where to Find Site Search Terms in GA4?

As with most things in analytics, configuring settings and sending data to GA4 is one thing, but finding it in different reports where you can use it to analyze is another thing. The same is the case with site search terms.

There are four ways you can find the site search terms in GA4:

  1. Testing in DebugView
  2. Real-time Report
  3. Events Report
  4. Custom Report in Explore

Let’s see how you can view your values with all these methods within the GA4 interface.

Testing in DebugView

DebugView is a great feature that lets us see the details of different events that are coming into GA4 in real-time.

Generally, you won’t need to use this method if your URL has default query parameters.

But if you have added a different query parameter and/or any additional parameters, then you can test whether it is working in DebugView or not.

Once you’re in the debug mode, go to ConfigureDebugView and perform a search on your website.

You can see that the view_search_results event has been triggered. You can click on that event and look at the search_term parameter to find the term you searched for.

Real-time Report

Another place where you can see the view_search_results event and the search_term parameters is under ReportsReal-timeEvent count by Event name card.

Event count by Event name card under Real-time overview to view_search_results event

To view the search terms, simply click the view_search_results event and you will see several parameters. Select search_term. You can now see different search terms and how many times they’ve been searched.

Search_term event under the Event count by Event name card showing the total count, and search terms with their individual counts

While this report gives you a quick overview of the terms, it isn’t very detailed, which brings us to the third method.

Events Report

Since view_search_results is an event, the Events report under Engagement has some more results. Once there, find the view_search_results, which can be at the bottom, and click on it.

Events report under Engagement reports showing the view_search_results event

In this detailed report, you can find all the search terms for any specific time, the Event Count, and the Total Users under the Search_Term card.

Search_Term card under the view_search_results event showing the search terms, event count, and total users found in the Events report of Engagement section in GA4

💡 Top Tip: You can also find other details about the view_search_results event in this report’s other cards like the page location, referrer, country, and gender.

Custom Report in Explore

The problem with the other three reports is that they are somewhat limited and you cannot customize them much. However, creating a custom report in Explore can give us more flexibility and information.

Let’s pick a free-form report from the Explore section and rename it Site Search Report (or whatever name suits you). 

When you start, you will see some segments, dimensions, and metrics added by default. You can remove all of them except the Event name dimension and the Event count metric under the Variables column, like this:

Keeping Event name in dimensions and Event count in metrics in the Variables section of the free form report under Explore

Next, click on the ‘+’ icon on dimensions, type ‘search term’, and click on the Import button.

Add Search term as dimension in the free-form report under the Variables column

In the next part, we will add the Search term dimension under the Rows and Event count metric under the Values of the Tab settings column. You can do it by double-clicking on the dimension/metric or by dragging and dropping it.

Adding Search term dimension under the Rows and Event count metric under the Values of the Tab settings column in the free-form Site Search Report

You will now see a report like this on the right side.

Free-form report showing the search terms and the event counts after adding the Search term dimension under the Rows and Event count metrics under the Values in Tab settings

However, there’s a small problem in the first row, where the Search term is blank and the event count is unusually high. 

We can fix that by applying a filter under the Tab settings column, by using the Event name dimension we had earlier left under the Variables column.

Click on Filters and select Event name.

Filtering with Event name under the tab settings column

Configure the Event name to exactly matchesview_search_results. Click Apply.

Creating and applying the Event name filter with exactly matches condition and using view_search_results as event

Finally, you’re all set to view your Site Search Terms report.

Final free-form report showing the search terms, the event counts, and event count per user after adding the view_search_results event name filter in Tab settings

You can also add other dimensions, metrics, and segments to further analyze your search term report. 

For instance, we added an Event count per user to get an idea of how many users have searched that particular term to get more context.

You can maybe apply a segment for mobile devices or a particular location and see more specific results, but that part is up to you.

Why Are You Seeing Low Site Search Volume?

Now, you’ve set up the site search report in GA4 and are not seeing a lot of site search terms there.

There could be three major reasons for this:

  1. Your site search bar is not visible or tucked away somewhere that is difficult for the website visitors to find it. You might want to bring it right on the top header section, which is a standard most people expect.
  1. Your Search Term Query Parameter is different or changed later on compared to what’s available by default in GA4, and you haven’t added the one that shows in your site search URL in the GA4 settings interface. Adding it in the enhanced measurement site search settings should fix it.
  1. Your site search bar does not function properly or is not even available on the website. This could be fixed from within your CMS, or by having your developer add one.

Other reasons could be that your site search URL has no query parameters for the search results, or the auto-complete functionality makes it difficult for GA4’s enhanced measurement to capture them.

In this case, we can use GTM to send the site search event to GA4 with different methods, a topic for another time.

FAQ

How can I implement site search tracking in GA4?

By default, site search in GA4 is tracked if you haven’t turned off the enhanced measurement. To configure site search settings:
1. Go to Admin → Data Streams.
2. Select the desired stream.
3. Click on the gear icon to access the site search configuration.
4. Show the advanced settings.
5. Specify the query parameters for search terms and additional parameters to track.

Where can I find site search terms in GA4?

There are several ways to find site search terms in GA4:

1. Testing in DebugView: Allows you to see real-time event details, including search terms.
2. Real-time Report: Under Reports → Real-time → Event count by Event name, you can view the view_search_results event and search_term parameter.
3. Events Report: In the Engagement section, navigate to the Events report and find the view_search_results event, which provides a detailed overview of search terms.
4. Custom Report in Explore: Create a custom report in the Explore section, adding the search term dimension and event count metric to analyze search terms in more depth.

Why am I seeing low site search volume in GA4?

There could be several reasons for low site search volume:

1. Poor visibility of the site search bar: Ensure the search bar is easily accessible to website visitors, preferably in the top header section.
2. Incorrect or missing Search Term Query Parameter: If your query parameter for search terms differs from the default ones in GA4, make sure to add it in the site search settings.
3. Malfunctioning or unavailable site search bar: Check if the search bar is functioning correctly or consult with your CMS or developer to address any issues.
4. Lack of query parameters or auto-complete functionality: If your site search URL lacks query parameters or auto-complete interferes with tracking, consider using Google Tag Manager (GTM) or alternative methods to capture site search events.

Summary

We have covered why it is important to track site search in GA4 and how to do it.

You are now aware of how you can add any different search query parameters compared to what’s available in GA4 by default. If you have a bit more advanced site search with filters, then you can track the additional parameters in GA4.

More importantly, you now know how to view the site search terms in the DebugView as well as in three other reports to find the site search terms, including a custom report which you can always customize further with more dimensions, metrics, segments, and filters.

Finally, you learned several reasons for seeing a low site search volume and how some of them can be fixed while others can also be tracked if we unleash GTM’s powers.

If you’re interested in recognizing how far a user has scrolled on a web page to improve the user experience, check out our guide on how to set up scroll tracking in GA4 which we recently published.

Don’t forget to tell us and our readers in the comments if you are tracking site search terms in GA4 and how it affects your understanding of the website visitors and helps to improve their experience.

Usman Qureshi

Usman is a web analytics content creator at MeasureSchool. He holds a master's degree in digital marketing from UCD Michael Smurfit Graduate Business School. He is a data enthusiast who enjoys different shades of it, whether it's analysis, implementation, or visualization.

Related Posts

WooCommerce Google Analytics 4 Tracking blog featured image

WooCommerce Google Analytics 4 Tracking Guide

Eric Huguenin

Google Analytics 4 Cookieless Tracking blog featured image

Demystifying Google Analytics 4 Cookieless Tracking

Eric Huguenin

Google Tag Manager Lookup Table Variable blog featured image

How to Use Google Tag Manager Lookup Table Variable

Usman Qureshi

Subscribe
Notify of
guest
12 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Ashkan
Ashkan
2 years ago

Thank you for the detailed blog. Can you please make a similar guide but about the live search functionality with AJAX calls? What’s the best way of capturing those search keywords?

Subham
Subham
2 years ago
Reply to  Ashkan

Yes, I also want to do the same (Similar guide but about the live search functionality with AJAX calls).

Subham
Subham
2 years ago
Reply to  Ashkan

Thanks for rising such a topic.

David
David
1 year ago

We have the Search box at the top of every page on our site and I’d like to figure out not only the number of searches but the pages where people are searching from as well. Any ideas on that one? Thanks.

Julian Juenemann
Admin
Julian Juenemann
1 year ago
Reply to  David

What ideas are you looking for? The implementation depends on how your search works.

Michael Buescher
Michael Buescher
1 year ago

This is an amzingly detailed blog post about something so valuable for people using Google Adwords and wanting to find out how to tweak their Ad so more people are findong you the right way! Some things that may help the post. I was not able to find DeBug mode, but I will look further. Unfortunately for me under the Events Report there is no category view_search_results event so I am not able to complete any process to find out the search trigger. Could this be called something else? Is there anything else I can search for that might get… Read more »

Julian Juenemann
Admin
Julian Juenemann
1 year ago

Hi Michael, I guess you are confusing events. This event fires when a user searches for something on your website directly if you have a search bar implemented (for example, they are looking for a specific product that you sell). It is tracked automatically if you have Enhanced Measurement enabled.

Ben Samson
Ben Samson
1 year ago

Hi Julian,
my search term url is /search.aspx?r=. How would I term that in the site search.
Thanks so much

Bhupinder Bhogal
Bhupinder Bhogal
1 year ago

Thanks for the guide. Whats really annoying is that we can’t see the impact of site search on conversion rates, revenue etc. That we could in the old version of GA!

Julian Juenemann
Admin
Julian Juenemann
1 year ago

well, the data is still there. But yes, UA made it easier to surface that insight. Now you need to build a report yourself that would show that information

Rom
Rom
1 year ago

Hi! One of my query search parameters is “price”, i.e.: “shop[.]domain[.]com/phones/green-phones?price=15000-30000. I added the parameter on the Additional Query Parameters field on the Site Search days ago, but no string is showing up on my reports, and/or explorations. Do you know why this may be?

Bryan
Bryan
1 year ago

Thanks so much for the article. One thing I’ve been trying to figure out, with view_search_results, there’s seemingly a built in event parameter, search_term. I’ve been trying to figure out how I can get access to the parameter outside of view_search_results. I’m creating a tag that fires at the same time view_search_results fires, and I see search_term in view_search_results, I’m trying to get that same search_term in my tag, but I don’t see the variable anywhere for me to use? Any thoughts?

Thank you,
Bryan

NOW IT'S TIME TO

Start Measuring Like A Master

Itching to jump into the world of MeasureMasters? This is what you have to look forward to.

Ready to take your digital marketing to the next level?

Subscribe to our newsletter and stay ahead with our latest tips and strategies.