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.
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 allows you to place custom variables via SetVar. It consists of the domain hash, followed by the custom variable.
UTMZ
…[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?