Adaptive Mind

Zero Results Search Terms in Google Analytics (async edition)

Posted on: 14. června 2011


Why should we bother? Because it is actionable!

Internal search is the best place to gather feedback from your potential customers. They come to your website and tell you:

  • what they want to find there;
  • where did they gave up trying to navigate there and used search functionality instead.

But what do they do if they see an empty results page? Some might try to refine their search phrase, but I would say that it really doesn’t improve their overall experience.

It also might be the good signal for you to:

  • deliver content that is not currently present on your website;
  • change copywriting a bit in case you have picked a different words for the content;
  • or try to implement a manually added results for those searches.


This article is meant to describe possible solutions when you are using a newer asynchronous Google Analytics tracking code placed in the head section of your website.

Google Analytics doesn’t provide this report by default. So we will have to do some extra work to achieve this. The first thing that is necessary to do is to be sure that you are able to identify a zero search results page programmatically.

Then you need to be able to manipulate the Google Analytics Tracking Script a bit or include an extra block of JavaScript into the tracked page.

Options to consider

You certainly don’t want to use an extra _trackPageview call, because this would inflate your data (especially Pages per Visit metric).

In certain cases you actually might be able to modify the tracked URL, but it can be achieved only in particular Web Content Management Systems that are able to pass in all the variables from the page into any template fragment of the generated page. With this capability, you could manipulate the tracked URL as described in this article by Justin Cutroni. The resulting code might look a bit like this:

<script type="text/javascript">
       var _gaq = _gaq || [],
             p = document.location.pathname,
             s =;

       _gaq.push(['_setAccount', 'UA-15436952-1']);
<? if (resultsCount == 0) { ?>
       _gaq.push(['_trackPageview', p + s + '&category=no-results']);
<? } else {?>
<? } ?>
       (function() {
    know this part...

Afterwards you can proceed with the Site Search functionality configuration by the instructions from Justin’s article.

If you don’t have such a comfortable CMS, you can still measure some extra data with the two following features of Google analytics.

Event Tracking

This method was already described in the article Using Google Analytics to Track ‘Zero Results Found’ for Site Searches by Bob Scavilla. I would just point out that it might be a lot easier if the actual search term would be generated by the CMS so you won’t have to suck it from the URL with a regular expression. The resulting code looks much simpler thought:

<? if (resultsCount == 0) { ?>
<script type="text/javascript">
<? } ?>

Custom Variables

The first thing you can do is to use a page-level custom variable. You can store the actual zero results search terms like this:

<? if (resultsCount == 0) { ?>
<script type="text/javascript">
<? } ?>

or you can store the particular results count:

<script type="text/javascript">

Then if you are a little advanced, you can use the API to show all search terms and their count of results in one report (using ga:searchKeyword and ga:customVarValue1 dimensions and ga:pageviews metric).


The only downturn of some of these methods is that the Site Search Terms report still includes all the searches that ended up with no results and you cannot really distinguish them.

6 komentářů to "Zero Results Search Terms in Google Analytics (async edition)"

Lukas, velice dobry blog post. Mimochodom, nevies nahodou ako setup tracking ked chces track ‚discount codes‘ v google analytics? Dik. Jan

Zabudol som dodat, ze chceme pouzit customVariables. Mame tento kod
, ale neviem kde alebo ako to umiestnit do google analytics code alebo na webstranku. Dik. Jan

Asi přesně nerozumím, čeho se snažíš dosáhnout. Pokud znáš daný promo kód z backendu, můžeš to udělat takto:
Jen dej pozor, že Custom Variable musíš nastavit před voláním _trackPageview nebo po nastavení Custom Variable odeslat virtuální pageview nebo event, jinak se proměnná nezměří.

tynto tyzden sme vyskusali pridat trackEvent funkciu onsubmit=“_gaq.push([‚_setCustomVar‘,1,’PromoCode‘, “, 3]);_gaq.push([‘trackEvent’,’dummy-ignore’,’ignore’];
avsak stale nemame ziadne data v GA. Mne sa zda, ze nas problem je nespravne ulozenie kodu na stranke. Momentalne mame kod na ‚apply discount code‘ button.

Asi bych to musel vidět, abych vám byl schopen poradit. Může jít např. o to, že váš button nemusí spouštět submit event nebo se skript před odesláním nestihne vykonat (obvykle se to řeší krátkým timeoutem). Obecně bych neradil používat tento způsob vkládání JavaScriptu – raději bych volil nějaký event attachment přes knihovnu unobtrusive cestou.

The game in itself is just about similar to lotto game and bingo and the result entirely is determined by chance.

Napsat komentář k Lukáš Zaplatílek Zrušit odpověď na komentář

Vyplňte detaily níže nebo klikněte na ikonu pro přihlášení:


Komentujete pomocí vašeho účtu. Odhlásit /  Změnit )

Google photo

Komentujete pomocí vašeho Google účtu. Odhlásit /  Změnit )

Twitter picture

Komentujete pomocí vašeho Twitter účtu. Odhlásit /  Změnit )

Facebook photo

Komentujete pomocí vašeho Facebook účtu. Odhlásit /  Změnit )

Připojování k %s

Sleduj mě na Twitteru

Moje twíty

  • "Za všechna opatření přijímám plnou 'politickou' odpovědnost" znamená, "když něco poseru, tak mě příště nemusíte volit, ju?" 5 days ago
  • RT @MeasureCamp: 📊Analytics companies Sponsor #MeasureCamp 👩‍💻Gain access to industry decision makers 🌏2019 had events in 24 cities from… 2 weeks ago
  • Ráno Vystrčil oznámil cestu na Taiwan a hned večer přichází tvrdá odveta. Bude v Událostech, komentářích s Okamurou. 1 month ago
  • Otcovské úspěchy: při pokusu nabrat lávu do kbelíku upečen v lávě, při pokusu postavit lávku přes údolí na placku.…… 2 months ago

RSS Google Reader

  • Objevila se chyba, RSS zdroj je pravděpodobně mimo provoz. Zkuste to později.


  • Objevila se chyba, RSS zdroj je pravděpodobně mimo provoz. Zkuste to později.
%d blogerům se to líbí: