How to set up Site Search in Google Analytics

If you don’t have site search set up yet, it’s time to fix that. Site search is an oft forgotten source of some of the most valuable data out there: what your customers want from you. This could be hot products you’re not yet stocking in your ecommerce store or popular content topics you could be writing about on your blog.

Fortunately for us, Google have made it as simple as it is possible to be to get this set up. So, here I’ll take a closer look at how you can set up Site Search in both Universal Analytics and Google Analytics 4.

Finding the search parameter

Both flavours of Google Analytics use the same core principle for tracking Site Search: detecting a search parameter in the URL.

So, the first thing you need to do is find which query parameter on your site contains the search term, this is usually “q”, “s”, “query”, or something similar.

If you have multiple types of search, you also want to check for a parameter which identifies the type of search being used.

Here’s an example for the Builtvisible blog, our search parameter is “s”, and our category parameter is “post_type”:

https://builtvisible.com/?s=my+test+search+term&post_type=post

Setting up Site Search reports

Once you have that, head over to the View Settings and scroll to the bottom, where you’ll find a section for enabling and configuring the Site Search reports.

Toggle site search tracking to “ON”, then enter the search parameter you found earlier into the “Query parameter field”.

If you had a category parameter, you could also toggle site search categories to “ON” and enter that parameter in here. This is entirely optional.

Should you strip queries?

You’ll have noticed that both search parameters can be stripped out of the URL, but should you do this? This is a matter of personal opinion, but I firmly believe the answer is: “yes”.

With search terms in the URL, your search page will be split into hundreds of rows which will make it near impossible to use this data in understanding user journeys. By removing the query parameter, you will have just one line per search results page – much tidier.

You’ll notice we haven’t stripped ours, this is because we don’t have a dedicated results page, so we’re using an advanced filter to replace the queries with a virtual “/search” path.

No search parameter

The vast majority of sites will use query parameters for site search data, but not all site will use this architecture. Progressive Web Apps (PWAs) are particularly likely to use alternatives, as they don’t generate page loads as the user navigates through the site.

If your data exists in the URL, but not in a query parameter, you can use an advanced filter in Google Analytics to change this.

The exact filter you need will depend on your URL structure, but here’s an example where the search term is set as a folder in the page path:

Advanced filter

If you don’t have any search data in your URLs, have your developers push the search term into the data layer on the search results page; you can then append a query parameter to the URL for that hit using Google Tag Manager.

Google Analytics 4 (GA4)

In GA4, site search is included in Enhanced Measurement. Google have even pre-filled the settings with the most common search parameters for you, so it’s even easier to get going!

Head over to your Data Streams, select your Web Stream, and check if Enhanced Measurement is measuring Site Search:

GA4 enhanced measurement

If it’s not, just click the cog on the right and toggle it on from the list. Be sure to expand the advanced settings for this one; you’ll want to check your search parameter is one of the defaults or add it if it’s not.

If you want to set up search categories, you can add it as one of the 10 additional query parameters.

Are your search filters in the URL? Why not add those as well while you’re there? You can have up to 10 additional search parameters, just add them as a comma-separated list.

Site search settings GA4

Don’t miss out!

Site search is a really important feature, as it provides us with some valuable insight into what our customers actually want from us.

It’s also one of the easiest features to set up across both Universal Analytics and GA4, so there’s really no excuse for missing out!

We’ll be dropping some tips on how to get even more actionable insight out of these reports very soon – why not sign up to our newsletter, so you don’t miss them?

Need a hand creating those pesky GA4 reports? Why not get some help from one of our Data Consultants?

Join the Inner Circle

Industry leading insights direct to your inbox every month.