Upcoming LunaMetrics Events
San Francisco, Apr 28-30 Los Angeles, May 12-16 New York City, May 19-23 Chicago, Jun 16-18

Google Analytics Custom Variables, Part I: Why?




Google Analytics recently introduced custom variables as a way to keep track of information about your visitors beyond the stuff that Google Analytics already knows about them.

What is a custom variable?

GA already records whether someone is a new or returning visitor, from which country and city they’re browsing, from what campaign or keyword or link they arrived at your site, and more.

crayons

But sometimes you know other information about your visitors that you might want to keep track of in GA as well. Your CRM system might have demographic information about people, for example. (We’ll look at some more examples below.) If you stored this information in Google Analytics, with the use of Advanced Segments you could see whether males between 25-45 with kids were more likely to purchase than females 18-25 with no kids (or whatever).

Didn’t Google Analytics already have this?

Before “custom variables”, there was the “user-defined segment”. Notice the singular “segment” vs. plural “variables”. You used to have to do all sorts of contortions to store more than one value with this feature. Now, with custom variables, you can easily store multiple values.

(Please note: If you’re using the old user-defined segment, Google hasn’t announced that it will go away any time soon. But clearly custom variables are the way of the future.)

Scopes and how to use them

We’re not going to talk about the technical details of custom variables (we’ll save that for a later post). But I do want to talk about one important property that they have called “scope”.

The scope basically indicates to what level of detail in Google Analytics the variable should apply. The scope can be visitor, session, or pageview.

Visitor level variables are much like the old user-defined segment. They get stored in a cookie for the visitor and apply every time that visitor returns to the site. This scope is best used for properties that are intrinsic to the visitor, or at least semi-permanent. You might want to record such things as:

  • Demographic information: age, gender, income, family, occupation, etc.
  • Customer information: “member” or “subscriber” or “gold club”
  • Original source information: how did they originally find out about us

Session level variables apply only to the single session (visit) during which they are recorded. They’re great for particular behaviors that occur during a visit, such as:

  • Added an item to the shopping cart.
  • Viewed a particular section of the site.

Pageview level variable apply only to the single pageview during which they are recorded, potentially including such things as:

  • Marked a page as a “favorite”.
  • Notified a friend about an article.
  • Viewed another tab within a page.

(Note that using pageview-level variables potentially have some overlap with event tracking. It’s up to you which model works better for particular actions on your site.)

More about custom variables

Now that you have some idea about why you might want to use custom variables, we’ll talk about how to actually make use of them in later blog posts. Check back soon for another post in this series.

Jonathan Weber

About Jonathan Weber

Jonathan Weber is the Data Evangelist at LunaMetrics. He spreads the principles of analytics through our training seminars all over the East coast. The next seminar he'll be leading will be a Google Analytics training in Boston. Before he caught the analytics bug, he worked in information architecture. He holds a Master’s degree from the University of Pittsburgh School of Information Sciences. Jonathan’s breadth of knowledge – from statistics to analysis to library science – is somewhat overwhelming.

http://www.lunametrics.com/blog/2010/04/15/google-analytics-custom-variables-part/

6 Responses to “Google Analytics Custom Variables, Part I: Why?”

To me, the real power of custom variables is the ability to use the data for advanced segmentation.

Custom variables are very powerfull… You can go up to the 5 custom variables by gather several custom variable in one.

Ophir Prusak says:

You can actually get more than 5 custom variables. It’s just not documented.

Here are the details:
http://analyticsimpact.com/2010/05/24/get-more-than-5-custom-variables-in-google-analytics/

Joe says:

I have a question about the visitor scope.
Suppose I have multiple tiers of members visiting my site.
browser->buyer->VIP
I can see how I would use the visitor session to group those users. However what happens if a VIP member cancels his subscription. Can I change the session variable back to buyer? If I do, will my historical data be corrupted or is it only for the data going forward?

Robbin Steif Robbin Steif says:

If it is session level (which is what I am understanding, now that I reread this), it applies to this session in its entirety, but there is no history (other than this session) to change.

A good way to change the session variable would be if you had a cancellation page (“sorry to see you go”) that stuck “buyer” back into that slot.

However, instead of using a session-level variable, you might want to consider a visitor-level variable. It makes more sense for this kind of situation. And with a visitor-level variable, it will change future data only but not for the current session. Consider this article on how to use the slots: http://www.lunametrics.com/blog/2010/07/23/custom-variables-part-iii-slots/

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