Blog

Underused Google Analytics Features - Part Four

Alistair Dent

Alistair Dent, 06 August 2009


In this installment: Zero results tracking for site search.

Part one, part two, part three.

Scenario: imagine that you’re on a website. You’re looking for a product. You try a few categories, they don’t seem to make much sense. You try a search, no results. Do you:

a) assume you did the wrong search and try again;

b) stop searching because the site clearly doesn’t have what you’re looking for?

My guessing is that if you’re anything like most people, you’ll go for option b. There are plenty more sites out there, you can find the product you need elsewhere, right?

ted-baker

Well it turns out this is how most people behave. But most website owners don’t know that. They don’t know how many people find no results on their searches and they don’t know what searches people perform that are leading to these zero results pages. Maybe there is a term that is relevant and getting a lot of searches but that isn’t yet a product on the site. Want to know what your customers want that isn’t already there? It’s in your zero search results.

But there is a solution. Virtual pageviews.

Virtual pageviews are used to take advantage of a feature of the _trackPageview function in the Google Analytics (GA) code. This function runs when the page is loaded and sends information to the GA system that a page has been viewed. When you call this function in the default code, you don’t pass any arguments to it. You have empty parantheses afterwords. In this situation when the function is called it can tell that the parantheses are empty fills in a default page to send to Google. The default page is always the page that the code is located on. So in normal operation, this lets GA fill all the content reports showing which pages have been viewed.

However, the parantheses don’t have to be empty. You can fill them with a page URL (minus the domain) and it will use this information to override the default. This page URL doesn’t have to be the real URL of the page.

The result of this is known as a “virtual pageview”. It means that when that page is loaded, Google hasn’t recorded that page in the system. Instead it has recorded a load of the page specified in the parantheses. There is no need for that to be a real page.

How does that help us with site search?

Well when your search page returns the results, if there are none there will usually be (and if there isn’t you can add one) a variable in the code (php or otherwise) to show the number of results returned. So you modify the ga.js javascript to include an if statement. The logic should go like this:

If _results = 0 Then
	_trackPageview("/zeroresults/term=xxx")
Else
	_trackPageview()
End If

The logic above (this is not code, just a general description of what it should do) will mean that the page URL sent to Google isn’t reported as a search, instead it is reported as a normal page in the content report. Now you can filter for pages viewed containing “/zeroresults” and see all the searches performed that didn’t return anything.

Note: do not make “term” the same as your standard search query. You want to keep these pages out of your site search tracking to avoid double counting. Keep successful searches in your site search tracking, and unsuccessful searches in this part of your content report.

zero results

Tags:



Leave a Comment