skip to navigation skip to content

Google Analytics Cookies and their values

In the previous article I showed you how to view Google Analytics cookies using Chrome Developer tools. You’ll notice first of all that there isn’t 1 cookie used by Google Analytics, and also each of these cookies has a unique name. If you look under the ‘value’ column you can see the actual contents of these cookies. Looking in the expires column you can also see when the browser will automatically delete/remove these cookies from your machine.

Why am I pointing all this out? In my opinion understanding what’s inside these cookies and when they expire is an important part of understanding how Google Analytics works, this goes a long way toward understanding how we calculate various metrics you see in Google Analytics reports as you’ll hopefully see in future posts. For now though let’s focus on what’s inside of each of these cookies.

Identifying the various cookies

All Google Analytics cookies, have a name beginning with double-underscore, then utm eg: __utm. Along with a unique name, each of these cookies has a specific purpose:

  • __utma = Unique visitor cookie
  • __utmb = Session or visit cookie
  • __utmc = Session cookie (deprecated)
  • __utmv = custom variable cookie
  • __utmz = campaign cookie (stores information about where the visitor come from)
  • __utmx = Content experiments combination cookie
  • __utmxx = Content experiments (reserved cookie)

__utma – Unique Visitor Cookie

It’s called the unique visitor cookie because it stores a visitor ID that is unique to each visitor on your site. This is so Google Analytics can provide the unique visitors metric. If you refer back to my previous article you’ll notice the values in this cookie for my web-browser were:

57446972.1220010577.1363822925.1364158984.1364161465.4

In each Google Analytics cookie values are often separated by by a period (.) character. I’ll dissect each value and what they mean as we go, with that in mind if we replace the numbers above with names the _utma cookie would look something like this:

domainHash.UniqueVisitorID.firstVisit.lastVisit.currentVisit.visitCount

Domain Hash

This value is unique for each domain (hostname) which Google Analytics is installed on. It’s purpose is to help Google Analytics know which cookie set to read from.

Cookie set is a term I use to refer to a group of Google Analytics cookies. Since configuring Google Analytics can get complicated depending on the amount of top level domains and or sub-domains in use, under some circumstances you may have a situation where Google Analytics wouldn’t necessarily know which cookie set it should read and write to. The domain hash is used to help Google Analytics understand which cookies it should use.

The domain hash value can also sometimes be set to just a single digit 1. This happens when you call the Google Analytics tracking code methods like _setDomainName(“none”) or _setAllowHash(false). Which we really need another article to discuss so we won’t cover that here.

However for now all you need to know is the number should be unique per domain you track. This is achieved by reading the current domain value and through an algorithm the Google Analytics javascript (ga.js) creates a unique number. Since every domain name must be unique and no 2 people can own the same domain name, no 2 domain hashes are the same.

Unique Visitor ID

This value is calculated by the Google Analytics javascript based on a quasi similar function to math.random (creates a random number) and assigned to visitors the first time they visit our website. In other words no 2 visitors will have the same ID assigned to them.

Q. What happens If I delete my cookies and visit the site again? A. The next time I visit the site I’ll be assigned a new number, hence I’m viewed as a new visitor.

Timestamp of first visit

Hang on a minute, did you say timestamp? Yes that’s right, however it’s a UNIX timestamp. So in order to translate these seemingly random numbers into an actual date you can use a utility like this conversion website. This value therefore translates into a date format like: Wed, 20 Mar 2013 23:42:05 GMT

Timestamp of last visit

Like the first visit above, but this is the timestamp of the last open session or visit to the website.

Timestamp of current visit

Again like those above, this is the timestamp for the current open visit on the website.

It should be noted that the first time you visit a website the 3 timestamps above can have the same value.

Visit count

The last value in the _utma cookie. How many times have we visited this website before? I’ve visited this website 4 times. Each new visit will cause this counter to increment (increase by 1).

__utmb – Session Cookie

So far I’ve thrown around the term visit and session without really clarifying what they mean. Well it’s actually a rather tricky thing to define. The first thing you should know is that a visit or session in the context of Google Analytics means the same thing. The way I like to think about a visit or session is that it’s a snapshot of activity on a website (or within an application) in a defined amount of time.

For example a visit can contain multiple pageviews, multiple events and even multiple conversions. A visit or session can be thought of as a container or grouping of user-based activity on a website. A session is usually deemed to have ended after 30 mins of inactivity (default for ga.js), said another way a session ends when a user has not actively engaged with content on the website for more than 30 mins.

I wrote a full detailed explanation on exactly how we calculate a visit in Google Analytics that can be found in the official Google Analytics help centre (told you it was hard to exactly define!).

Example values:
57446972.1.10.1364340483

domainHash.hitCount..currentVisit

I’ve already explained the domainHash above so I’ll skip to:

Hit Count

Each pageview, event, transaction, social action you trigger in a given visit is referred to as a hit or request. So if you view 3 pages on a website that’s 3 requests that get sent to Google Analytics. This counter keeps track of how many requests are made. It’s main purpose is to help throttle requests – i.e prevent a flood of requests in a short time frame from a given user.

Suffice to say I don’t know what this number represents and to be honest with you I’m able to resolve most issues/questions about Google Analytics over the last 4.5 years without knowing. My advice don’t worry about it. If you do know what it does, leave a comment below for me though.

Current Visit Timestamp

No different to what was mentioned already in __utma above

The real important thing about __utmb is not it’s contents but when it expires! You see if you continue to navigate a website, that is view additional pages, trigger events this cookies deletion time gets extended 30 mins into the future. When you do nothing or leave a website for more than 30 mins this cookie is removed from your browser. It’s the absence of this cookie that initiates Google Analytics to open a new visit/session.

__utmc – end of session cookie

Back before we had tabbed browsing (think of old Internet Explorer 6), we used to open new windows in our web browsers instead. Closing a window would also cause session cookies to be removed from the browser. Hence this cookie used to be deleted when you closed the open window and like __utmb above it’s absence would trigger Google Analytics to begin a new visit / session.

However this cookie is no longer used and is ignored by Google Analytics (ga.js). The legacy (urchin.js) library may still leverage this cookie, but if you’re still using the old urchin.js javascript you should be ashamed of yourself – really!

_utmv – custom variables

By default most websites won’t have this cookie configured. This cookie will appear if your website calls the _setCustomVar method. Custom variables only store values in a cookie when the scope is set to 1. A scope defined as 2 or 3 will not be stored in the _utmv cookie.

Example method call:

_gaq.push([1,'user-type', 'registered', 1]);

In the above call we are saying store this in slot 1 (Google Analytics has 5 free slots for custom variables). We give the name of the custom variable user-type and the value registered since a common use for custom variables is to differentiate between visitor types i.e registered vs non-registered or guest users.

Finally we define the scope of 1. This creates the _utmv cookie. Here is an example value for _utmv

57446972.|1=user-type=registered=1

domainHash.|slot=name=value=scope

This cookie is configured to expire 2 years into the future. Also if you define additional custom variables in additional slots you’ll see more values stored in this cookie.

_utmz – campaign cookie

This is the mack daddy of Google Analytics cookies in my opinion because it allows Google Analytics to store where you came from… no not quite like that. It stores the campaign source (i.e direct, referral, organic, paid, campaign) that will be used to associate your visit with a particular traffic source.

Example value:

57446972.1366152253.9.2.utmgclid=TestAbC123|utmcsr=(not%20set)|utmccn=(not%20set)|utmcmd=(not%20set)|utmctr=keyword|utmcct=(not set)

Let’s first look at the values separated by period characters first..

domainHash.currentVisit.visitCount.campaignCount

We have already discussed domainHash (see above).

currentVisit = we also covered this in _utma (see above)

visitCount = we also covered in _utma (see above)

campaignCount – This count increases each time the campaign changes for this visitor. This is used to help generate reports such as those in Multi-Channel Funnels section of Google Analytics.

Now let’s take a look at the other values you may find in the _utmz cookie:

  • utmgclid = AdWords click id (when auto-tagging is used)
  • utmccn = campaign
  • utmcmd = medium
  • utmcsr = source
  • utmcct = creative
  • utmctr = keyword

The above will terminology will make more sense if you think in the context of the URL builder tool.

The _utmz cookie has an expiry of 6 months, but each subsequent pageview actually extends this expiry another 6 months from the date of the last interaction with the website. So this cookie will only be removed if a visitor does not return to your website within a 6 month period.

This is important to understand because I find that people are often confused when they see visits for an old campaign run several months ago (6 months+) appearing in their account. The reason is that a visitor from the old campaign is still returning to your website via a direct visit (direct url type in or bookmark) and these later direct visits are being attributed back to the last known campaign (or last non-direct campaign).

So that’s about it for the core cookies used by Google Analytics. I left out _utmx and _utmxx as they are specific to Content Experiments feature in Google Analytics and for now we won’t cover that. I will see what I can do about an in depth look at Content Experiments in a later post.

2 Responses to “Google Analytics Cookies and their values”

  1. I really enjoyed reading your article I now have a much better understanding about information stored in cookies and how this is used in the GA reports. Looking forward to reading your next article.

  2. Thanks Maria, I plan to continue to add more articles about GA in the coming months, be sure to check back soon.

Leave a Reply

Author

Gavin Doolan has been working with Google Analytics since it's launch in 2005.