Although some excellent guides on how to track zero result searches in Google Analytics have already been published in those blogs dedicated to digital analytics (including Justin Cutroni’s post here), I decided to offer a solution that:
- proposes the usage of Google Tag Manager
- allows you to track further actions of those users who received zero search results
Thus, not only would we be able to identify missing content on the site (or even a problem with the search engine), but it would also allow us to improve the nothing-found page to prevent users from abandoning the site after receiving zero search results.
The post is divided into the following chapters.
- Before we begin
- Identify zero result search page
- Configure a set-up to track zero result searches
- Track further actions
Before we delve into details on how to track zero result searches in Google Analytics via Google Tag Manager, let me remind you that there are existing services/tools that can provide you with this kind of data. For instance, Search Meter for WordPress. So, in case you have one of these tools installed on your website and you are totally satisfied with it, probably, there’s nothing much for you to learn here.
I would also recommend reading the following articles that provide an in-depth exploration of site search data in Google Analytics.
- Five questions to ask of your site search data by Avinash Kaushik
- Site search in Google Analytics by Samantha Barnes (Lunametrics)
Now, without more ado, let’s see how we can use Tag Manager to track zero result searches in Google Analytics.
First, we need to identify a search page with zero results. This can we be easily done by finding a unique attribute that is only specific to this particular page. Let’s take the zero result search page for my blog as an example.
As the screenshot implies, when a certain search query generates zero results, my
<H1> HTML tag has the value of “NOTHING FOUND”. I see no reasons why I can’t use that as a unique identifier.
To do that, let us first create a custom JS variable like this.
return (document.querySelector('h1.page-title') &&
document.querySelector('h1.page-title').innerText === 'NOTHING FOUND') &&
And name it like zeroResultSearch. Here’s an explanation. If there is a
<H1> tag on the page with the value of nothing found and the location search property start with “s=”, this function will return a truthy value. Otherwise, it will return false. Thus, we can be quite sure that the page is of ‘zero-result-search’ type.
Next, let’s identify the search query that has generated zero results. To do that, we simple need to create a URL variable with Query as a component type and our search term as query key. Let’s name it like siteSearchQuery.
Please do mind that you will need to use your own search term. For instance, “q”.
Configure a set-up to track zero result searches in Google Analytics
Finally, we need to send an event to GA once a certain query generates zero search results. Create a trigger like this:
And an event tag like this:
Thereby, you will have an event sent to GA each time when a certain search query does not produce any results. Not only that, you will also define the exact word/phrase that triggered the event.
Thus, you can acquire useful data that may help you improve the content of your website.
Now, when we are done with a set-up that allows us to track zero result searches in Google Analytics, let’s see how we can get the information concerning the behavior of those users who received no results.
Naturally, we would want to know if users refine their search. To perform this, we will simply track search form submissions on the zero-result page. Again, let us take my blog as an example.
Here is a trigger.
As you can see, I use previously created custom JS variable for the Enable When condition to make sure the trigger fires only on the page with zero search results and Form Element matches CSS selector form[role=”search”].search-form for the Fire On condition since that’s the easiest way to track search form submissions here.
Next, you should create a UA event tag and attach the above trigger to it. Thus, once users refine their search, you will have an event sent to GA.
We can also track link clicks located in the suggestion block. Thus, we acquire data on how this block performs. Here’ a trigger for my nothing-found page.
And here is the tag.
By adding Click URL as the event’s label we can see which suggestion works best for certain zero-result search queries.
The solutions listed here are DOM-dependent. This means that you will have to adjust them according to your site’s source code.
I hope this little tip will come in handy both for those who want to fix the Exit Search metric and those lacking data-based solutions for improving their website’s content.