VKI Studios is now Cardinal Path! www.CardinalPath.com
Learn more about Cardinal Path

GA Basics: The Structure of Cookie Values

I noticed today that a fair few people are coming to our site looking for information on the structure of Google Analytics cookie values. While this is the kind of topic that might make some peoples eyes glaze over, it's really not very difficult to understand. In fact, Google Analytics cookies are relatively straightforward and easy to understand.

Disclaimer: I haven't worked with these since I started studying for my GAIQ (and the analytics crew isn't here for me to check this with), so its possible that things have changed since. The major details should still be the same.

There are five main cookie types set by GA:

  • UTMA - The Visitor Identifier
  • UTMB - 30 Minute session identifier
  • UTMC - On Exit session identifier 
  • UTMV - Custom Variable Cookie
  • UTMZ - Visitor segmentation

UTMA

The UTMA cookie defines a visitor.

utma=123456789.123456789.1234567890.1234567890.1234567980.1

Domain Hash: The first number is the domain hash. This is set by all cookies from this domain.

Visitor ID: The second number is a random "unique ID".

Initial visit: The third number is the unix time stamp for the initial visit and is set as soon as you enter the site.

Note: by combining the random unique ID and the time stamp you get the Visitor ID for the session. This is what GA uses to determine unique visitors.

Previous Session: The third number is the unix time stamp for the previous session.

Current Session: The fourth nubmer is the unix time stamp for the current session.

Note: Time one page is determined by taking the time stamp of the current session and subtracting the time stamp of the previous session. Or in the case of the second page load, the current from the first. If you are on the first pageview of the site then all three numbers will be the same.

Session number: This is the number of the session. So if this data has been written once before (since the last time you cleared your cookies) then this number will be 2. 

UTMB & UTMC

UTMB and UTMC are both session identifiers. Generally these just contain the domain hash, and (in B's case) some times some additional values. The key with these two cookies is in their expiry date. UTMB expires after 30 minutes—unless it is re-written—indicating the end of a session. The UTMC expires when the user closes the browser. If either of these cookies expires then GA knows to end the session for that visitor.

UTMV

utmv=123456789.[customvar]

UTMV allows you to place custom variables via SetVar. It consists of the domain hash, followed by the custom variable.

UTMZ

utmz=123456789.1234567890.1.1.utmcsr=[source]|utmgclid=[ad click id]|utmccn=[campaign]|utmcmd=…
…[medium]|utmctr=[keyword]

UTMZ sets your visitor segmentation, and contains all of that fancy information about sources and campaigns that you love to look at.

Domain Hash: Yes, you guessed it, the first number is the domain hash.

Time Stamp: The second number is the time stamp.

Session #: Like in utma, this counts the visitors sessions.

Campaign #: This counts each time a visitor arrives from a different campaign.

utmcsr: This is the source of the visitor.

Mp>utmgclid: This is the Google ad click ID (thanks to Andy in the comments for bringing this omission to my attention)

utmccn: This is set by the campaign value of the url, or in the case of organic traffic it is (organic).

utmcmd: This is set by the medium defined by the URL.

utmctr: This is the keyword that brought the visitor here in search engine campaigns.

And there you have it: the basics of Google Cookies. Not nearly as mind numbing as they sound, eh?

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
I'm studying for GA IQ now and your explanation is way more straight forward than the GA video. (Some stuff is better explained in writing than in a video, but GA hasn't recognized that yet).

Do you have an equivalent blog post on regex? That's really painful via GA IQ video. Thanks.
# Posted By wendy w | 8/31/10 9:28 PM
Oooh I was just working on exactly that (regex for GA). Expect it in the next couple of weeks.
# Posted By KentC | 9/1/10 2:24 PM
Is cookie called UTMV also used by setCustomVar? Or it is only a cookie used by the old SetVar?
# Posted By Jarno Rossi | 9/2/10 3:05 PM
I'll need to double check with Brian Katz, but I'm pretty sure that setCustomVar sets __utmv as well.
# Posted By KentC | 9/2/10 3:55 PM
@Kent and @Jarno
Kent is spot on.
This is what a __utmv cookie would look like if it stored both a _setVar value and a _setCustomVar value:
70189199._setVarTest|1=Test _SetCustomVar=_SetCustomVarTest=1
Everything before the | is the same as the older version of the __utmv cookie before _setCustomVar came along.

Note, however, that _setCustomVar will ONLY write values to __utmv cookies that are in the Visitor level scope. Page Level and Session Level variables do not persist across visits and are therefore NOT written to __utmv.
# Posted By briankatz | 9/3/10 12:37 PM
Ok Brian, so how do we interpret that string?
1=Test _SetCustomVar=_SetCustomVarTest=1

The first 1 is the slot?
test_SetCustomVar is the string name?
_SetCustomVarTest is the string value?
The Second 1 is the scope?

Or is _SetCustomVarTest the string name, the second 1 its value, and there is no scope assigned?

edit: DOH! Should have read Brians post closer and noticed that only one scope gets written to utmv. So I guess the second interpretation is the correct one?

For those who are following this and a little lost, test_setCustomVar uses the following parameters:
index The slot used for the custom variable. Possible values are 1-5, inclusive.
name The name for the custom variable.
value The value for the custom variable.
opt_scope The scope used for the custom variable. Possible values are 1 for visitor-level, 2 for sesson-level, and 3 for page-level.
# Posted By KentC | 9/3/10 3:02 PM
Nice post. In my UTMZ I don't have a utmcrs. Instead I have a utmgclid. Would you explain this please? Thanks!
# Posted By Andy | 9/29/10 10:02 AM
Woha typo in my post. Should be utmcsr not utmcrs. You wouldn't have a value for this if you don't have a campaign source, though I'm unsure of whether the tag would be missing from the cookie.

As for utmgclid, that is the Google ad click ID. This is set by adwords auto tagging.
# Posted By KentC | 9/29/10 10:42 AM
.