Call 0845 485 1219
We love digital - Call
0845 485 1219 and say hello - Mon - Fri, 9am - 5pm
It is likely, whether you are in the industry or not, you have heard the term ‘cookie’ thrown around here and there – And unfortunately I don’t mean the chocolate chip kind. A cookie is a small text file which is stored in your browser as a means of giving memory to browsers and servers.
Originally created to help maintain customisation, the cookie contains data which is attached to the HTTP header of a page request, allowing the server to determine if you have any current customisations in place and whether or not you have the authority to view the page.
Google Analytics relies on cookies to ‘remember’ and record a users’ interaction on a website. In this blog post I am going to look at each of the specific cookies Google Analytics uses, the potential customisations and a way of using Google Debugger to see the cookie data.
Google Analytics uses a set of up to up to 4 cookies; _utma, _utmb, _utmz and _utmv via the ga.js library to record information about what a user has seen or done on a particular page. It sets these cookies at the domain specified in the document.host browser property and with the root level path.
It is important to remember that cookies are browser specific when it comes to ga.js. Therefore a user on Google Chrome on their work computer will have different cookies stored than if they are using Google Chrome on their home computer.
This cookie is used to determine new and returning visitors. It has an expiration time of 2 years. If the ga.js library is executed and no _utma cookie exists, this will be recorded as the users’ first visit and a _utma cookie will be set. If a _utma cookie is already in place, the expiration time is reset and the user is recorded as a return visitor.
This cookie is used to determine a new session. The cookie is set when the ga.js library executes and there is no _utmb cookie in place. It has an expiration time of 30 minutes, therefore if a user is inactive for a period longer than this, a new cookie will be set when the library executes and the interaction will be recorded as a new session.
This cookie is used for storing visitor-level custom variable data. It is created when the _setCustomVar method is used with a visitor level custom variable. Like the _utma cookie, this cookie expires after 2 years and is reset each time the user visits your site before the expiration of the cookie.
Although each of these cookies has a set expiration time, each time the ga.js library is executed and the expiration time has not been met the cookie is updated, resetting the expiration date to its original value.
For those of you who are already aware of cookies you may have noticed that I have left out _utmc. This is because strictly speaking it is not used within the ga.js library. This cookie expires when the browser is closed, therefore, for the purpose of this blog post I am going to overlook this cookie.
There are 5 key customisations which can be carried out on ga.js cookies:
By default domain name tracking will be set to the domain specified within the document.domain property. However, you can set this to either a specified domain name or ‘none’ . Setting the domain name allows you to implement cross domain tracking. For Example:
Would allow traffic from all Koozai subdomains to be tracked.
Setting the domain name to ‘none’ does the opposite of this and allows only traffic to the top level domain to be tracked.
Typically Google Analytics sets the cookie path to the root of your domain which is appropriate in most situations. However, you may wish to define the cookie path when you only have access to a sub-directory of a website. Therefore, you would set the cookie path as this sub-directory. For example:
Would only track interaction within the /Gemma folder of the website.
As mentioned above, the visitor cookie (_utma) has the expiration time of 2 years. _setVisitorCookieTimeout allows you to redefine this expiration period in milliseconds. Therefore _gaq.push([‘_setVisitorCookieTimeout’, 31,557,600,000]); would change this expiration time to one year.
_setSessionCookieTimeout and _SetCampaignCookieTimeout are also ways of altering the expiration times of their corresponding cookies. _setSessionCookieTimeout relates to the _utmb cookie and _SetCampaignCookieTimeout relates to the _utmz cookie. Remember all expiration times are defined in milliseconds.
If your cookies aren’t working it could mean that the data you are collecting in Google Analytics is incorrect meaning any decisions you make off the back of this data are inaccurate. Therefore it is important to check your cookies are tracking correctly. You can do this using a method covered by Nikki Rae at this year’s Brighton SEO.
So first of all you need to download the Google Analytics Debugger extension. With the Debugger switched on, go to ‘Advanced Settings’ in Google Chrome and ‘clear browsing data’.
Next you need to delete your cookies from the beginning of time:
Go to your site via a specific medium. In this instance I have visited Koozai via Google, therefore, the visit should be tracked as organic.
To see the information which would have been sent to Google Analytics press CTRL+SHIFT+J.
As you can see this has been tracked as my first session (correct as the cookies had been cleared) and via organic source (Correct!).
Ok, now go back to the Advanced settings in Chrome. Click ‘Content Settings’.
And choose ‘All Cookies and Site Data’.
Find your website and you can see which cookies are being stored on your browser.
For the purpose of this blog post we are going to ignore WRUID and _CT_Data.
So if we click on _utma we can identify whether or not we are being tracked as a unique user (this should be the case as all cookies had been cleared).
So let’s go through a quick run through of what the string of numbers means. The string starts with a domain hash, this defines which domain the cookie relates to and is unique for every domain. The Unique Identifier is what defines the user/browser. The time stamp refers to the visits the user makes to your website and the number of sessions refers to how many times they have visited your website. Therefore, in this case we can see that I have been recorded as a unique visitor because all three time stamps are the same.
The _utmb cookie contains the same domain hash as above. This cookie records information about this particular session. To check it is working we can review the number of page views (in this case one) – Correct!
Update: I have been informed the pageview counter actually refers to a hit counter. Therefore, it is not recommended not to try and and determine the pageview of a visit via the _utmb cookie value.
Again the domain is the same as the above cookies as it refers to the same domain. From this cookie we are able to determine the campaign source, campaign name, campaign medium and campaign terms. As I visited Koozai.com via organic traffic through Google and I am logged in to my Gmail account it would appear this cookie is working. The source has been recorded as Google, the medium as Organic and the search term as (not provided). Traffic source information can also include utm_source, utm_medium, utm_term etc.
So there you have it, a nice simple check to be sure your cookies are working as they should be. When you do this check do you have any issues with your cookies? Do you have another method for checking your cookies? I would be very interested to know in the comments.
Data Mining Information via BigStock Photo
Copyright © 2006 - 2014, Koozai Ltd