Google Analytics Custom Variables Overview

Today Google releases Custom Variables (cv for short) in Google Analytics. This is an evolution of the custom segmentation feature. This post is meant to give you an overview of the feature. We’ll discuss how to use it in a later post.

Like Custom Segmentation, custom variables are a flexible way to add more information to Google Analytics. The big difference is that you can create LOTS of custom variables. How many? In theory you can set an infinite number of custom variables. But GA has some internal limits that keep you to 50,000.

What can we use custom variables for? The possibilities are endless:

  • Segmenting members from non-members
  • Segmenting customers from non-customers
  • Tracking all the campaigns a visitor sees prior to converting
  • Content categorization
  • Segmenting visitors based on landing page
  • Visitor segmentation based on demographic info
  • Customer segmentation based on order history

Google Analytics Custom Variables are like data decorations!

As my friend Phil likes to say, custom variables are decorations that you hang on your data. Almost like holiday decorations hanging on a tree! This is a really good analogy that I’ll continue in this post.

There are four critical attributes of a custom variable that we must understand in order to use them.

Name and Value

The easiest attributes to understand are Name and Value. The Name of a custom variable is literally the name you give to the variable. Each variable can have many, many values. For example, you could define a variable named ‘Baseball Team’ and then add the values:

  • Red Sox
  • Yankees
  • Phillies
  • Giants
  • Angels

This is totally different than the old Custom Segmentation feature. With Custom Segmentation you were limited to one variable (ie one Name) that could contain multiple values. Now you can create multiple variables each of which can have multiple values.

You can view all of your variable names in the new Custom Variables report.

Google Analytics Custom Variables Report

It’s important to note that the name of a variable, plus the value for a variable must be less than 64 characters. Why? The data is sent to Google via a request for an image file. The actual length of the request is limited and Google wants to insure that all of the data makes it to the server.


Google Analytics custom variables depends on the scope of the variable.

The real power of custom variables comes with something called the Scope. Think of scope as the different ‘levels’ of visitor data. When a visitor visits a website Google Analytics collects data at three levels:

  • Pageview level: This is data associated with each page viewed during a visits. Page level data can change from one page to the next.
  • Visit level: This is data associated with the visitor’s entire visit. This data can change from one visit to the next. But visit level data is applied to every page within a visit. This data only exists for the CURRENT visits.
  • Visitor Level: This data is applied to the visitor and every visit and every pageview that the visitor generates. This data persists across all visits that a person creates. How does it persist? Via a cookie.

This means we can set information, ie custom variables, at the page level, the visit level and the visitor level. If we think of custom variables as decorations “hanging” on our data then we could use the following graphic:

GA Custom Variables "hanging" on your data.

So scope is the same as level. Anyone drooling out there?

The ability to control the scope of a custom variable makes this feature extremely flexible. For example, if you want to group all of the content on your site you can add a page level custom variable to every page that identifies the groups that a page belongs to.

If you want to segment visitors by their purchase history you can add visitor level custom variable. The possibilities are truly endless.

Let’s take a look at some of the reporting so you can get a feel for some of the data.

Here’s the Custom Variables report. You’ll notice it looks a lot like the user defined report. This report contains all of the variables that you defined. If you click on a variable you’ll see all of the VALUES for that variable.

So why has google added a scope if we can’t see it in the reports? I’m just going to let you guys speculate. But it’s obviously a critical part of CVs and we should see that data.


The last attribute that we need to discuss is something called the Index. To be honest, it’s really hard to define the index. Basically the index is a technical attribute that helps GA organize all the custom variables on a page.

It’s only used during the implementation, so we’re not going to dig any further in this post.

Speaking of the implementation, you’ve probably noticed that I haven’t talked much about the implementation. To be honest, we’re still playing with CVs. Obviously this data comes from JavaScript. So you have to do some coding to get this data.

But I’m going to hold off on the implementation talk until later. Implementation involves another concept called the Index which is, to be honest, vague and confusing.

Be Sociable, Share!

    Like this post? Sign up to get posts delivered to your inbox.


    1. says

      Great writeup Justin. I was curious if you had an idea when custom variables will be exposed in the interface. I can’t seem to find it.

      I believe the Google Analytics announcement mentioned it would be ready in a ‘couple of weeks’.

    2. says

      Many thanks Justin:

      Do we need to send custom variables before the new Custom Variables report shows up or will there be a new empty report once it is enabled in my profile?

      If the new report is not available yet, can we already send custom variables?

      Great stuff!


    3. says

      Great writeup – thanks for the easy to grasp analogy about scope.

      I’m unable to find the custom variables report in GA. Can you point me in the right direction?

      • Justin says

        @phil: Absolutely. Custom variables will be perfect for tracking content by author. I would use a page level custom variable to group your content by author.

        @yulai: The new visitor scope Custom Variable uses the same cookie as the old user Defined feature. So you can’t use them together. I would use the new custom variables as userDefined will not be supported in the future.

        @mike: Yes, I’m going to update the CRM script to extract the visitor level custom variable and pipe it into a CRM.

        @ryan: Yes, you could use custom variables to track page load times, but I suggest using events. Check out this article on tracking page load times with events.

        @Leonas: The actual number of custom variables that you can set is variable because of scope. A variable’s scope determines how long the variable will last and that changes how many slots are available for custom variables. I’ve got to get a blog post done on scope, I’ll try to have it done soon.

    4. says

      I am using Google Analytics on my site and I am wondering if I can use custom variables to track how long it takes my pages to load when someone visits? Do you have any suggestions?

    5. says

      This is the best explanation for CVs I read, And oh boy did I read…
      Looking forward to reading some implementation examples…

    6. yulia says

      Hi! Thanks for the clear explanation. I’ve been trying to figure out these custom variables for a while now…

      Can this new variable be used along with the old user defined variables? I set this one up, but now my old user defined variable report got new values like : “oldterm|1_newname_newvalue_1,”
      Is that normal? I can’t figure out what’s going on…

    7. says


      how long does it take for the data to appear?

      Is there anything that needs to be configured in the reports to make it work?

      I’ve been waiting over two days now and still no data is appearing.


    8. says

      I want to tracks visits by authors, should I use the custom variable or add an additional trackpageview looking like _trackPageview(“/by/author/Douglas Karr”);

      what do you think ?

      • Justin says

        For all those asking where the Custom Variables report is, you can find it in Visitors > Custom Variables.


    9. says

      Hi Justin,

      i added some custom variables but still nothing on the report. sounds similar to waht @mark is saying. Do we need to switch it on somewhere?

    10. says

      oops. just appeared.. was about 36 hours after the test. the event tracking appeared withing a few hours. but the customer vars took much longer

    11. Stephen says

      I am looking to use a custom variable at the pageview level to view how traffic behaves to a dynamic homepage. Can a dynamic value be set within the CV?

      For example, the homepage for the site changes on a daily basis. I would like to still view the homepage within my analytics as a pageview but then be able to see the data for each different version of the page. I believe the best way to do this is pass a dynamic value into the custom variable.

      It is kind of similar to tracking different categories except it would be different versions of the same page. Do you know of any examples of something similar?

      • says

        @Stephen: You can pass any value you want into a custom variable. When your homepage loads you’ll need to dynamically choose a value for the custom var using JavaScript (or server side code) and then add that the custom var code.

      • says

        @ Alessio: I’m not sure what you are asking, but you can use both custom variables and events on the same site. They are completely different pieces of data that have their own specific JavaScript..

    12. XYZ says

      I have a question on using custom variables in GA code. My requirement is: I have 5 varbales (which can be saved in 5 different slot) and I want to give multiple values to those variables and want to maitain all the values in GA custom variables. For example, I have a variable named : StudentName(slot 1; scope 1), StudentRollNumber(slot 2; scope 1) etc. In first hit I provided the values as Neha(StudentName) and 1(StudentRollNumber ). In the second hit I provided the values as Preeti(StudentName) and 2(StudentRollNumber ).. In the third hit, values are Pooja(StudentName) and 3(StudentRollNumber ) and so on..

      Now if i check in GA, I should get:
      StudentName(slot 1) StudentRollNumber(slot 2)
      Neha 1
      Preeti 2
      Pooja 3

      But right now I am not getting all the values.. I am getting only the last values. It is not adding the values. Values are getting updated. Is there any problem with the scope? Which scope should I use in order to retreive all the values? Please reply..

      • says

        @ XYZ (Is that your real name?) – I’m assuming you are trying to track individual people using the website? If that is the case then you should not have any problems using just two visitor level custom variables. When someone logs into the site, or registers, you should set two visitor scoped custom variables. This means that each user will get two custom variables stored in two slots. You get 5 custom variables per user, not across all users.

        HOWEVER, there is a MAJOR problem with what you want to do. The Google Analytics terms of service states that you can not store any personally identifiable information in Google Analytics. That includes names. So I would recommend that you do not store StudentName in a CV. Roll number is also considered personally identifiable.

        Hope that helps.


    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>