Site Search In Google Analytics ‑ With Or Without Query Parameters
Google Analytics comes with a lot of features “out-of-the-box”, but one of the reports that you will need to configure is the site search report. If you haven’t used this feature yet and you have a search box on your site, keep reading!
The site search reports provide data on what type of content people are looking for on your site. Having site search data is like reading the minds of a subset of your audience. 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
You will notice that the Site Search report is located under Behavior in the left-hand navigation and not Acquisition, where organic and paid search data is located. That’s because these reports are related to internal searches only – a behavior someone can perform on your site that returns results pages that are also on your site.
Site search tracking is not automatic like pageview tracking because there’s a wide variety of site search engines that function differently and because not every site has an internal search or wants to track that!
How you will set up your site’s search analytics will depend on what type of website you have and how it behaves. This may involve a simple one-click process, an advanced view filter, or a bit 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 keyword. The simplest way to do this is to go to your site and perform a search for something, anything! On the following page, take a look at the URL – do you see your keyword?
Most site 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 keyword in a pattern that looks like the following:
Page Paths – appear in the middle of the URL, with no query parameters, and can look like the following:
Site Search with Queries
If you’ve identified that your search keywords show up in the query parameter portion of the site, you’re in luck! This is the easiest way to set up site search.
Site search settings are view-level, so they are located under Admin > View [the view you would like to configure] > View Settings. Below the AdWords settings, there will be an option to turn on the site search tracking. After switching it on, an empty field will appear titled ‘Query parameter.’
The next step is to 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 ’s’, though the actual query used will vary from site to site. Some other examples you may see are ‘q’, ‘searchTerm,’ ‘term’, and ‘keyword.’
It is easy to identify the query when there is only one parameter on the end of the url, but keep in mind that some sites have multiple queries for other purposes, so our keyword may show up somewhere else in the URL after an ampersand (&).
Once you have identified the query where your search keywords show up, you can then go back to the site search settings, fill in the search query (in this case, ‘s’) and you’re done!
This field must be populated in order to turn on the site search reports. If your site uses page paths or another method, you will still have to enter a ‘dummy’ parameter here. Any string or letter can be entered, just make sure your site 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 bloat to your report, and also is unnecessary since we will be able to see the individual keyword data in the site search report.
Page Path Search Terms (No Queries)
Another common behavior of site search, specifically with Drupal, 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 involve different 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.
After choosing the filter name, select ‘Custom’ and ‘Advanced’ in the filter’s settings.
Next, we will choose ‘Request URI’ for Field A since we are getting the information from the URI, or page path. Your site’s page path goes in the text box, so for this example, it would look like below:
When we do 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- so we are storing anything after the slash.
Field B will be blank since we are only concerned with extracting from the page path and nowhere else. The next field, ‘Output To’, is the one we are interested in. Now that we have stored the keyword from the URI, we need to output it to the correct dimension.
In the dropdown menu, select ‘Search Term’ and type ‘$A1’ into the input box. This tells Google Analytics to grab the user-defined value from Field A and output it as a search term. For the checkbox options below, only ‘Field A Required’ and ‘Override Output Field’ need to be selected.
Once you are done, the settings should look like the following:
After you save the filter, your site search should be ready to start tracking. However, with this set-up you will still see the search keywords show up in your content reports and split your search results pages. If you have a site with a lot of search activity, this could potentially created hundreds of additional rows.
Stripping Keywords from the URL
Remember the setting we used to strip queries out of the URL? We can emulate that by using another filter.
In the same view where you 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 our example, this would be ‘/search/site/.*‘. The second input box is what we want to replace the former page path with. Since we are just 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.
Once you have this tool, you can start to analyze internal search data and begin asking questions like:
- “Should we take another look at the usability of our navigation? More than 10% of people are using our site’s search engine.”
- “A lot of people from organic channels are looking for terms not related to our business. Why we are ranking for non-relevant keywords?”
- “We are seeing trends of certain keywords. Should we feature this content more clearly on the site?”
You’ll notice that these reports will be relevant not only to your web analysts, but also to SEO, UX and even your design team.