Set up Site Search - Google Analytics

Set up Site Search – Google Analytics Help

Rate this article

Share this article

In this article, we’ll track the search queries which are giving no results. Tracking no search results are very important as you might be missing out on potential customers who are searching for something and not getting any results.

If you are using Expertrec Search you don’t need to do any setup and you can skip the setup section and jump on Checking NoResults trends in Google analytics.

Let’s get started on how to track zero-result queries in google analytics:

You would need to figure out how zero results look according to your website.

Here is a sample of no search result

no result found

 

 

Quick Fix

For the above case:

You can run a little javascript to find the element which contains the above no search result text and if the element exists send an event to google analytics.

Note: The code totally depends on your website. The below code may not work at all

function getQuery() {
  return document.getElementById('search-text').text;
}

window.onload = function() {
  if(document.getElementById('no-search-results') {
    ga('send', 'event', 'Search', 'ZeroResults', getQuery())
  }
}

Steps that are required

I’ll break down the steps that are required to get your own code running for tracking zero-result queries in google analytics

  • Find out your no search result page type.
  • If it is a page, write a function to use the javascript location variable to figure out that it’s no search results page.
  • If it is an element, write a function to use a CSS selector to check if the element exists using javascript.
  • Write a function to get the query from the input box or URL path/query parameters.
  • Once you have your functions ready call the function to check if you are on a no search result page.
  • If you are, get the search query and run the below script.

ga(‘send’, ‘event’, ‘Search’, ‘ZeroResults’, ‘SearchQuery’);

The parameters passed are:

  • ‘Search’ – Sending a search event to Google Analytics.
  • ‘ZeroResults’ – Name of the category under which zero results should be tracked.
  • ‘SearchQuery’ – Search query for which there were zero results.

Note: The above code may vary based on your integration of Google Analytics

There’s a simpler way of tracking zero-result queries in google analytics. You don’t need to follow all the above steps and break your head over it. ExpertRec search will directly integrate zero search results on your website with google analytics.

 

code to easily track zero search results using google analytics

Sign up for expertRec custom site search

If you have integrated google analytics as per the latest recommendations by Google, you are already tracking search queries as well as zero-result queries in google analytics with expertRec.

If you have added it in a different way or as per the old recommendation you can go to the prerendered page in the dashboard and update your GA tracking snippet for no search results there.

 Checking NoResults trends

    1. In Google Analytics Dashboard

Once this setup is done, you can check the ZeroResult query In Google Analytics under Behaviour -> Events -> Top Events. Select the event category: Search and event action: ZeroResults.

ZeroResult Google Analytics

 

  • In Google Data Studio

 

You can also use Google data studio to see search insight.

Google Studio

    • Copy report and change the data source to your google analyticsGoogle Data studio Setup Step2

Now you will be able to see a report like above.

 

Add Search to your Website

Are you showing the right products, to the right shoppers, at the right time? Contact us to know more.
You may also like