Segmentation is the mother of all website optimization. That's an extreme statement, but I believe anyone in the field would think twice before disagreeing with it. Segmentation enables us to understand who are our customers and how different groups of people behave on the website; this information is extremely valuable in order to provide a a richer and more relevant experience to customers. The result is a happier customer, a more profitable website, and more bonuses to Web Analysts!
That's why Avinash Kaushik is so vehement when he writes: The Choice Is Stark: Segment Or Die! According to him: "if you simply sit and ponder for a few minutes it will be clear that your website exists to do many different jobs and people come to your website to accomplish many different goals. So why analyze your data as one big ugly glob?"

Google Analytics provides several out of the box ways to segment your visitors into groups. For example, it is possible to segment by GEO location, Browser, Operating System, Traffic Source, Visitor Type (New vs. Returning), Content Viewed, Goal Completion, and the list goes on...
But beyond a shadow of a doubt, the most powerful segmentation feature on Google Analytics is the Custom Variable. I like to play with the idea that Custom Variables are so important that they should have their own tab in the Google Analytics sidebar navigation, and that this tab should be significantly prominent. Here is a mockup for the Google Analytics team, feel free to use!

Below I discuss a proper definition of Custom Variables, where it should be used, how to plan its implementation, and some additional tips and tricks.
According to the Google Analytics Code site, Custom Variables can be defined as:
Custom variables are name-value pair tags that you can insert in your tracking code in order to refine Google Analytics tracking. With custom variables, you can define additional segments to apply to your visitors other than the ones already provided by Analytics.
The important part of this definition is that you, as the website owner, can define the segment that you want to apply to specific visitors. The missing part of this definition is that you can apply it to your visitors only after they actively do something on the site. For example, you can define someone as a male or female only after he or she fills in that information on the site. That may seem obvious, but it is important.
The power of Custom Variables is partly due to its hierarchy, the possibility to define whether the segment you are creating will last only for the current page visited by a visitor, the current visit of a visitor, or "to infinity ... and beyond!" (i.e. for as long as visitors keep their cookies).
I will go over some examples below, but before it is important to understand how Custom Variables are defined, their grammar. First, as mentioned above, we can use different levels, meaning that the variable will be saved for different periods of time:
But before you start jumping out of joy, please note that if you are using the free version of Google Analytics you have only 5 slots. That means you have to think carefully before you implement them. If you are a lucky person, and you have Google Analytics Premium, you will have 50 slots available, which is a lot!
As I mentioned above, this is not an out of the box feature, so you will need to implement code in order to collect this data. Below is the code and the explanation for each parameter:
_setCustomVar(index, name, value, opt_scope)
index (required) — The slot for the custom variable, it can range from 1 - 5 for standard accounts or 1-50 for Premium accounts.
name (required) — The name for the custom variable, a string that identifies the custom variable and appears in the top-level Custom Variables report of the Analytics reports. For example, if you are using a slot to track gender, the name would be 'Gender'.
value (required) — The value for the custom variable, it appears in the table list of the UI for a selected variable name. Typically, you will have two or more values for a given name. Using the 'Gender' example above, the values would be either 'Male' or 'Female'.
opt_scope (optional) — The scope for the custom variable. As described above, the scope defines the level of user engagement with the site. It is a number whose possible values are 1 (visitor-level), 2 (session-level), or 3 (page-level). When left undefined, the custom variable scope defaults to page-level interaction.
As mentioned above, standard Google Analytics users have only 5 slots available. So it is important to plan Custom Variables implementation effectively. The most important thing is to be careful when overwriting slots.
For example, if you use slot 1 to track visitors who register to the website, do not use it to track visitors' gender as well, one will overwrite the other. However, you might consider using slot 1 to track Purchase, as if you know someone purchased something, you don't need to know he ius registered anymore, so overwriting it is OK. For visit and page level variables it is easier plan, but note that if you trigger two different variables in one visit, the last one will get the full credit for all the visit.
Below I provide examples of usage for each Custom Variable level.
Let's suppose you have the following registration form on your website (screenshot below). Your visitors have to enter all that information in order to register, which means you can use any of it in your custom variables, right? Wrong! The first rule you need to know is that tracking Personal Identifiable Information is against Google Analytics Terms of Service (see section 7). Therefore, you should not add emails and names to your custom variables.
![]()
Using the example above, you would probably want to track the following using a Visitor Level Custom Variable:
Visit Level Custom Variables are extremely valuable when tracking internal campaigns. Let's suppose you have an Ecommerce website and you are advertising different products on your homepage. If you trigger a Custom Variable (using an onclick event) for each of the product in your homepage you will be able to understand which products are driving more sales from the homepage. This will be extremely valuable when defining how to organize your content in a data-driven way.

Please note that while this might sound like Science fiction to some people, the implementation should be very simple (considering standard conditions for temperature and pressure). Here is a similar code of what you would add to you HTML link tag: onclick="_gaq.push(['_setCustomVar',1,'Home Campaign','Galaxy Nexus',2]);"
Page Level Custom Variables should be used in order to group actions performed in different sections of the website. Here are a few examples:
When it comes to using Custom Variables for Ecommerce websites, Justin Cutroni provides a very useful list of ideas (implementation and analysis details on this link):
Here are four advanced issues you should keep in the back of your mind:
As mentioned above, Custom Variables are the most powerful segmentation feature on Google Analytics, it enables marketers to understand their visitors better. On The Choice Is Stark: Segment Or Die! Avinash starts by saying:
There is a reason your analytics data does not make any sense. There is a reason you are unable to find an iota of insight that you can action. There is a reason you feel data is your enemy. You see, you are not following one of the holiest of holy covenants when it comes to data analysis: Segmentation.
If you are among this group, get started now!
Subscribe To Our Newsletter For Monthly Updates
Hi Daniel,
I quite often see your comments amongst the GACP forum. I have to say I have always been 90% knowledgeable on Custom Vars, today and because of this very informative post I am 100% knowledgeable, so thank you very much. what did it for me was 'The missing part of this definition is that you can apply it to your visitors only after they actively do something on the site.' This is so obvious but an element of which I have over-looked and had so many questions with the data that CV's provide.
Brilliant Daniel, thank you for such an informative and to be honest THE best post I have read on CV's in the past two years.
Sean
Google Analytics is a must have if you can not afford a paid web analytics tools like omniture, web trends or any other. GA is easy to implememt, use and there is lots of online resources from where you can learn about google analytics. One such possts that can help mid level executives to use analytics data is at aGreat post one such i found and think it could be also beneficial for users is at http://searchenginemind.com/make-web-analytics-data-informative-and-insi...
Let's say I want to change the way the custom variables are used. Is there a way to reset those values? So if I use CV 1 for showing author names and instead use dates. Is there a way to reset those variables by the date?
Rad, there is a way to delete old custom variables by using the method _deleteCustomVar(). I hope it helps.
Interesting contradiction in this post. An example of an onclick event to trigger a custom var on session level (visit level). At the end some advanced tips & tricks where you mention that the setCustomVar method always should be called before the trackPageview method.
Do I miss the clue?
Anonymous, as I said in the end of the article, the Custom Variable must always come before an event or a pageview. This happens because the _setCustomVar does not send a hit to Google Analytics, so it waits for the next hit (an event or pageview). Usually, you can set the Custom Variable and trigger an Event right afterwards to be sure it is sent to Google Analytics.
Hi Daniel,
Thanks for the explanation. Would it be a good use of Custom Vars to track what service customers are searching for (in a travel search box, for example). So setting up 1 slot for country, 1 slot for city, 1 slot for roundtrip/one-way, etc? If so, how would you go about setting up all the values for something like the Country (which would have a list of 200 or so values)? I'm just a little confused about how exactly they work!
Thanks Adrian. Is there a specific for you not to use Google Analytics Internal Search? That is a great feature if you are looking to track searches in your site. Then, you can use advanced segments to analyze searches per country. So unless you have a specific issue with the Internal Search feature I wouldn't recommend using Custom Variables for that.