How to Set Up Site Search in Google Analytics

Do you want to track what your visitors are searching for on your website? 

You can do it using the site search tracking feature of Google Analytics. It helps us understand what keywords people are entering into our website search box. This is valuable information that we shouldn’t miss out on. It tells us what will keep users on our site, and what we may need to add if it’s missing. 

In this guide, we will see how we can configure site search on our website using the query parameter in the website URL that appears after a search.

Here’s an overview of what we’ll cover in this guide:

So without further ado, let’s dive into Google Analytics and configure our site search.

URL Query Strings Explained

All right, to get started, we are here on the official merchandise store of Google. And we have access to the Google Analytics merchandise store demo account.

We can see the data in this demo account. Now, under the reports section, when we go to Behaviour → Site Search → Search Terms, we see that we have tracking data about what the user has searched for on the website. 

Search Terms under Behaviour report of Google Analytics

So, when you search in the search bar of the merchandise store, it triggers an internal site search and displays the search results.

Search option in the merchandise store

Now, how can you configure Google Analytics for your own website to learn what users are searching for? Google Analytics has built-in functionality to pick up such searches, and it’s all based on the URL of your website.  

In the back of the URL, we have a query string. If you look at the URL, you’ll notice it has a question mark. Everything behind the question mark is called a query string. 

We have certain information that is encoded in this query string. One distinct piece of information here is the keyword which equals test. Now, the test is the keyword that we searched for on the website. Therefore this is the actual search term that we would like to record.

Query string in the URL of your website

Let’s try another example with the search term t-shirt.

The search takes us to the results page. And here again, we see that keyword equals t-shirt

Query string of the URL to set up site search in Google Analytics

So, these search terms are something that we would like to track in Google Analytics. 

Now every time you enter a new page, it sends over information to Google Analytics by default. Because the search query becomes part of the query string, we can track site searches using URLs. With the tracking code that you have installed, this information gets sent and a pageview is recorded within Google Analytics.

Set Up Site Search Based on a Query Parameter

Since the URL is also transferred to Google Analytics, what we need to tell Google Analytics is that we have a certain keyword in the URL that is always after the equals sign. 

So how can we tell Google Analytics what to look for? It’s actually pretty easy. 

For this, under the Admin section, go to View Settings → View, and here we have a section called Site Search Settings. You just need to turn on the Site search Tracking option. 

And then put in the Query parameter so that Google Analytics knows where to look in the URL. 

Then you can select Strip query parameters out of the URL. So when we look at URLs inside of Google Analytics, we don’t see keyword equals whatever the search term was. This is particularly important when you don’t want to have your reports broken up by search terms.

Optionally, we could also turn on the Site search categories. But that’s something that would need to be in your query string as well.

Site Search Settings under Admin Section in Google Analytics

Now that you know how to set up a site search based on a query parameter, let’s try it out. I’m going to put in a search term in our demo shop. This will take us to the result page and display our keyword.

Now when we look in the URL, we again see a query string and it has our search term encoded. This time an equal sign with an s precedes it. So s is the keyword that Google Analytics should pull up. 

Keyword in the URL query string of the search result page

Now, let us go to the View Settings under the Admin section in our Google Analytics account.

We then scroll down and turn on the Site search Tracking and enter our Query parameter

The Query parameter should be the word that precedes the equals sign so that Google Analytics can identify it. Here it will be s. In our earlier example i.e. for the merchandise store, it was keyword. 

Now, let’s go ahead and enter the Query parameter as s into Google Analytics.

Also, let’s select the Strip query parameters out of the URL option. Leave the Site search categories untouched because we don’t have a category parameter. 

Click on the Save button and we get the Success message.

Configuring the Site search Tracking in Google Analytics

And now we should be able to view our data in the reporting section under Behaviour → Site Search → Search Terms

However, when we search for something on a website and it gets sent over to Google Analytics, it goes through a processing engine. And therefore, it will take a while till our results are reflected in our report. 

So this is how you can set up site search tracking with the help of Google Analytics and query parameters. 

What if You Don’t Have a Query Parameter?

Now, if you don’t have query parameters in your search box, then you would need to track your site search separately. You can do this with the help of Google Tag Manager in a couple of different ways, which you may need to experiment with.


This is how you can configure your Google Analytics site search. Isn’t this a useful  feature of Google Analytics? 

At its simplest, site search tracking can help you analyze your website visitors’ behavior and what they’re looking for just by using the query parameter.

To take your analysis further, you can also label a visitor of your website using Google Analytics. 

Feel free to comment below on how you set up a site search for your website. Have you tried site search tracking with Google Analytics? Or do you prefer setting it up with Google Tag Manager?

If you’re looking for more support on Google Analytics and Google Tag Manager, you might also want to check out our free beginners’ video courses.

About the author: Julian Juenemann

Julian started and grew venture-backed startups with his unique 'data first' approach to Online Marketing. He then founded to help marketers, like him, the data-driven way of digital marketing.

Inline Feedbacks
View all comments