by Aime


Implementation of Google Analytics

Real Implementation of Custom Variables in Classic Google Analytics

Many technical blogs dedicated to custom variables exist out there. But the sad reality is that the high majority of those blogs present custom variables as a simple snippet taken out of context. As a consequence, the real customisation/ implementation of custom variables becomes more than challenging for many developers, to say the least.

Thus, the primary objective of this article is to bridge that gap, complement and present with clear examples, with a context, how to really customise and implement custom variables in classic Google Analytics.

Primarily, as it is often presented, here is the normal Async GA code snippet:
_gaq.push([‘_setCustomVar’, index, name, value, scope]);

Hypothetically, let’s assume that you are an analyst or a developer for the

Let’s say that you are tasked to implement the classic Google Analytics on your site. Your first and trivial job will be to paste into all Guardian’s pages, the Google Analytics tracking code. That code should look like this:

script type=”text/javascript”>
var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘UA-XX0007-X’]);
(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);

Let’s assume also that your boss has read the following blog post of Cutroni; and now, you are tasked to implement his new features: “Custom Variables”


Leave a comment

Your email address will not be published.

ConversionWorks is now Media.MonksVisit us at