• Jervis Koo

Setting Up Site Search in Google Analytics

Google Analytics comes with a load of features “out-of-the-box” but one of the reports that you will need to configure is the site search report. If this is a new feature to you and you have a search box on your website, read on!


The site search reports provide data on what type of content people are looking for on your website. You can easily see what they’re looking for, the words and terminology they are using and how quickly they found what they were looking for (or if they did at all!).


For most websites, you can set up the site search reports entirely within Google Analytics, without needing to modify anything on your website.


The Site Search Reports


The Site Search report is located under 'Behavior' in the left-hand navigation rather than 'Acquisition', where organic and paid search data is located. That's because these reports are related to internal searches only – a behaviour someone performs on your website that returns results pages, that are also on your website.


Site search tracking is done automatically like pageview tracking due to the wide variety of site search engines that function differently and also because not every website has an internal search bar or wants to track internal site searches.


Setting up your website’s search analytics will depend on the type of website you have and how it behaves. This may involve a simple one-click process, an advanced view filter, or potentially slightly more configuration with on-page code or Google Tag Manager.


Find Your Search Term

Before heading into Google Analytics to update your settings, you’ll need to locate your search term. The easiest way to do this is to go to your website and perform a search for something. It could anything! On the page/post that you selected page, take a look at the URL – do you see your search term?


Most websites will fall into one of two categories: query parameters or page paths.


Query Parameters appear at the end of a URL following a question mark. You may see your search term in the URL that looks like the following:


https://www.jerviskoo.com/?s=search+term


Page Paths appear in the middle of the URL, with no query parameters, and can look like the following:


https://www.jerviskoo.com/search/search+term


Site Search with Queries


If your search terms are showing up in the query parameter of your URL, you’re in luck! Setting up site search will be a breeze.


Site search settings are view-level on Google Analytics, you can find them located under Admin > View > View Settings. On the bottom half of the settings window, there will be an option to turn site search tracking on. After switching it on, an empty field will appear titled ‘Query parameter.’

Next, go to your website and perform a search. Look for a question mark in the address bar as well as your search term. In the examples below, the search query is ’q’, though the actual query used varies on different websites. Some other examples you may see are ‘s’, ‘searchTerm,’ ‘term’, and ‘keyword.’


It will be relatively easy to identify the query when there is only one parameter on the end of the URL, but keep in mind that certain websites might have multiple queries for other purposes, such as campaign linking so our search term may show up somewhere else in the URL after an ampersand (&).

When you have identified the query where your search terms show up, you can then go back to the site search settings, fill in the search query (in this case, ‘q’) and you’re done! You will be required to populate the field in order to turn on the site search reports on Google Analytics. If your website uses page paths or another method, you will still be required to enter a ‘dummy’ parameter here. Any string or letter can be entered, just make sure your website isn’t using a parameter that matches this for other purposes.


In most cases, you will also want to check the box to strip these queries out of the URL in Google Analytics. Keeping them will split views to the search results page into multiple rows in your page path report. This adds another level of detail to your report and is mostly unnecessary since we will be able to see the individual search term data in the site search report.


Page Path Search Terms (No Queries)


Something else that is common for site search is to have the terms appear within the page path instead of as a query. Neither is better or worse than the other, it will just require a different type of configuration in Google Analytics.


To track this type of site search, an advanced filter should be used for the views where you will be using these reports. First, navigate to Filters > New Filter under your view in Google Analytics.


After choosing the filter name, select ‘Custom’ and ‘Advanced’ in the filter’s settings.

Make sure you choose ‘Request URI’ for Field A since we are getting the information from the URI (page path). Your website’s page path goes in the text box, so for this example, it would look like below:



By doing this, we are telling Google Analytics to look at this page path and extract the characters from within the parentheses. The dot and asterisk are regular expressions representing any character and any number of characters, therefore, capturing everything after the slash.


We will be leaving Field B blank since we're only extracting the query from the page path and nowhere else. The next field, ‘Output To’, is the next thing we want to look at. Now that we have stored the keyword from the URI, we'll need to output it to the correct dimension.


Using the dropdown menu, select ‘Search Term’ and type ‘$A1’ into the input box. This query tells Google Analytics to grab the user-defined value from Field A (set earlier above) and output it as a search term. For the checkbox options, select ‘Field A Required’ and ‘Override Output Field’.


The settings should look like the following:

Hit "save" and your site search is ready to start tracking!

Stripping Search Terms from the URL

Another way to emulate stripping search queries from a URL would be using a filter.


In the same view where we implemented the advanced filter for site search, add a new filter. Select ‘Custom’ and ‘Search and Replace’ in the settings. The field dropdown should be ‘Request URI’ and in the first input box, type in the page path for your site searches along with the regular expression signifying ‘anything’.


In this example, this would be ‘/search/site/.*‘. The second input box is what we want to replace the former page path with. Because we are stripping out the keyword after the slash, we will type in the page path without the keyword – ‘/search/site/‘. This will aggregate your search results page into one row in the content reports.

Benefits

Implementing Site Search gives you the ability to analyse internal search data and get answers to questions like:


  • “Visitors from organic channels are looking for terms not related to our business. Why we are ranking for non-relevant keywords?”

  • “Do we need to take another look at the usability of our navigation? More than 20% of visitors are using our site’s search engine.”

  • “We are seeing trends of certain keywords. Should we feature this content more clearly on the site?”

These reports will not only be beneficial to web analysts but also to SEO, UX, and even design teams.