Adaptive Mind

Posts Tagged ‘english

Warning: this is pretty heavy JavaScript stuff.

If you’d ask what the most used web analytics solution is, you would probably get pretty obvious answer. But what is not so obvious to the most people who use Google Analytics is the fact that it is a piece of JavaScript and it can be customized a lot. Especially these days when we measure dynamic websites full of JavaScript features that stay hidden to the basic generated tracking script.

Frontend developers got used to benefit from JavaScript libraries like jQuery that help them not to write repetitive code, resolve a lot of cross-browsers issues and achieve a better maintainability of their code. And as I said before, Google Analytics Tracking Code (GATC) is just another piece of JavaScript that you include into your website, so why wouldn’t you give it the same treatment as to the rest of the scripts.

A little optimized basic asynchronous tracking script (Google recommends to put it into your document’s <head> section as an inline script):

var _gaq = [];


       ['_setAccount', 'UA-XXXXXX-X'],   // doplnit vlastní ID účtu




(function (d, t) {

       var g = d.createElement(t),

             s = d.getElementsByTagName(t)[0];

       g.async = 1;

       g.src = ("https:" === d.location.protocol ? "https://ssl" : "http://www");

       g.src += "";

       s.parentNode.insertBefore(g, s);

}(document, "script"));

With this article I would like to start a series of implementation tips that should help you to make the most of Google Analytics implementation using the features of the most popular JavaScript library jQuery.


And when I say that the tracking script is just another piece of JavaScript, I would give it a proper treatment also in terms of your website’s performance. Because the most of the setting script doesn’t change, you can remove it from the inline script block and include it (minimized) into a JavaScript bundle to:

  1. allow the browsers to cache some extra bytes of code;
  2. decrease the needed number of HTTP requests to your server.

Because we are going to use jQuery library, the only thing that you have to do is to make sure, that the library will be initialized, when we will need to use it. So I would recommend that jQuery is the first and our setting script the second script in the bundle. It might look like in this file.

First tip: Custom Events

With this functionality which is built-in the jQuery library you can easily measure activity of your website’s visitors that is purely controller by another JavaScript within a single page. You can use it for interactions with tabbed content, carousels, pagination or whatever you decided to implement in JavaScript or AJAX to enrich your visitor’s experience.

Somewhere within your JavaScript code:

// Fire Event

$(document).trigger("custom", [{

       param: "value"


The corresponding part handling the event:


$(document).bind("custom", function (e, extraParameters) {



The main advantage of this approach is that you can set some basic conventions for your frontend developers so they would fire a Custom Event on every measurable interaction. Then it is up to you whether you will implement the event’s handler to do the actual measurement.

Example 1: Measuring AJAX calls

You should probably measure only the successful requests, so the code might look like this:

// in the AJAX call definition


       url: "myurl.html",

       success: function(){

             // ...

             $(document).trigger("ajax:call", [{

                    trackURL: $(this).url




And when you decide to measure this event, you can simply extend your GATC


$(document).bind("ajax:call", function (e, extraParameters) {

       _gaq.push(["_trackPageview", extraParameters.trackURL]);



I hope this was somehow useful to you. I would like to continue with similar tips, so stay tuned.


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.

As promised I am going to accomplish my UXCampEurope Berlin 2010 participation. For those who missed the whole thing, I prepared an online survey to analyze which tools and methods that are used in UX industry do the real practitioners use and consider useful.

I tried to attract the participants by sharing the URL of the survey by giving the event attendees a physical notice (and I would like to thank Sigy for the „offline tweet idea“).

Photo by @mahemoff

The survey

The survey listed 19 user experience tools/methods in 5 categories:

  • Qualitative user research
    • Offline surveys/questionnaires
    • Online surveys
    • Remote user testing
    • Full-scale user testing
  • Quantitative user research
    • Eye tracking
    • Mouse tracking/screen recording
    • Web analytics
    • A-B/Multivariate testing
  • Information Architecture/Labeling
    • Card sorting/tree testing
    • Search keywords research/Text-ads testing
    • Mind maps
  • Wireframing and Prototyping
    • LoFi wireframes/mockups
    • HiFi wireframes
    • Non-functional prototypes
    • Full-functional prototypes
  • Interaction Design/Scenarios
    • Component/Widget libraries
    • Storyboards
    • Personas
    • Pageflows/Activity diagrams

and the participants were asked to answer how often they use such a tool and how useful do they think it is:

Usage frequency:
1-Never, 2-Rarely, 3-Regularly, 4-Often, 5-Every time
1-Worthless, 2-Informative, 3-Helpful, 4-Insightful, 5-Priceless


I hoped for more participants to be able to share significant results. After one week there are only 20 people who completed the form and I feel that I owe them at least some results so I will try to formulate a few hypotheses based merely on qualitative data.

There were 7 participants from Germany, 6 from Czech Republic, 3 from UK, 2 from Denmark, 1 from France and 1 from Spain.

Most of them stated their job title to be User Experience Designer, others are UX consultant, Analyst, Concept Developer, Information Architect and student. One participant was concerned that people in marketing industry might use these tools less often, but i don’t have enough data to support or confute this idea.


So lets start with the numbers. I normalized the data, so it can be read easier.

Survey results

These numbers show how the participants perceive the listed tools/methods in relation to each other on the scale from 0 (the least used and useful tool) to 100 (the most frequent and appreciated one).

Qualitative user research

I have to admit that these results don’t surprise me a lot. Almost everyone has read Steve Krug’s „Don’t Make Me Think!“ and we all agree that usability is the core attribute of every software product. I think the optimism around remote user testing is interesting although the participants haven’t used it a lot. It may be caused by the fact that these tools had a pretty extensive representation during this year’s UXCampEurope.

Participants also mentioned etnography research, (non)directed interviews, focus groups and other sorts of sessions with the target audience.

Quantitative user research

On the other hand web analytics are widely adopted. The pessimism about its usefulness may be caused by the information overload that hasn’t been successfully tackled yet by any software vendor providing on the market. There is also a positive anticipation around a-b/multivariate testing. The small penetration of mouse tracking and screen recording tools is something that surprised me, because fancy heat-maps produced by these tools are demanded and well received by clients.

Information Architecture/Labeling

I admit that this category was the most vaguely defined. But it seems that card sorting and mind maps are also pretty widespread and seen as satisfactory in general.

The participants also used task analysis and affinity diagrams. We can also argue wether mental models or cognitive walk-troughs belong into this category or should rather live within qualitative user research.

Wireframing and Prototyping

These few questions are in fact only another dimension in the area. I was interested if perfection is widely required in all stages of concept development. We can argue that it depends highly on the size of the projects, but I can see no trend in relying on perfect wireframes or prototypes so the concept phase overlaps with the product development.

Interaction Design/Scenarios

In the last category I was pretty surprised by the wide adoption of personas and storyboards, which might be caused by the grouping of the tools. Participants also mentioned swimlanes and object modeling in this category.


These results are not intended to be a full-scale statistically significant research as I didn’t pay much attention to recruiting participants or data cleanup. I just wanted to share an idea and provoke a discussion about the industry and the UX practitioners feelings about its overall maturity.

I am not saying that I managed the whole thing well, but I would really like to hear what you think about the topic rather than the survey itself.

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.