Adaptive Mind

Zero Results Search Terms in Google Analytics (async edition)

Posted on: 14. Červen 2011

Introduction

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.

Prerequisites

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 = document.location.search;

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

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">
       _gaq.push([
              '_trackEvent',
              'Search',
              'No-results',
              '<?=$searchTerm?>'
       ]);
</script>
<? } ?>

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">
       _gaq.push([
       		'_setCustomVar',
		1,
		'No-results',
		'<?=$searchTerm?>',
		3
	]);
</script>
<? } ?>

or you can store the particular results count:

<script type="text/javascript">
       _gaq.push([
       		'_setCustomVar',
		1,
		'Results-count',
		'<?=$resultsCount?>',
		3
	]);
</script>

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).

Conclusion

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.

5 odpovědí 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
_gaq.push([‚_setCustomVar‘,1,’PromoCode‘,“,3]);
, 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:
_gaq.push([‚_setCustomVar‘,1,’PromoCode‘,’KOD_Z_BACKENDU‘,3]);
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.

Napsat komentář

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

WordPress.com Logo

Komentujete pomocí vašeho WordPress.com účtu. Log Out / Změnit )

Twitter picture

Komentujete pomocí vašeho Twitter účtu. Log Out / Změnit )

Facebook photo

Komentujete pomocí vašeho Facebook účtu. Log Out / Změnit )

Google+ photo

Komentujete pomocí vašeho Google+ účtu. Log Out / Změnit )

Připojování k %s

Sleduj mě na Twitteru

Moje twíty

RSS Google Reader

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

RSS 417.cz

  • Objevila se chyba, RSS zdroj je pravděpodobně mimo provoz. Zkuste to později.
%d bloggers like this: