- ga.js (used in Classic Google Analytics)
- analytics.js (used in Universal Google Analytics)
- urchin.js (the oldest version of GA tracking code, not recommended anymore)
The ga.js library sets the following cookies:o1. _utma (visitor cookie) – This cookie is used to determine new and returning visitors on a website.
If the _utma cookie doesn’t exist on
user’s browser when the ga.js library is executed, Google Analytics will
consider that this is users’ first visit and will record this user as a new
visitor. At the same time GA will set up a _utma cookie on user’s
browser, whose default expiration time is 2 years.
The next time when the user comes back on the website, GA will recognize the _utma cookie and will consider him as a returning visitor.
Each time when the user comes back to the website, the cookies expiration time will be reset (with another 2 years).
The cookie is created when the
Its expiration time is 30 minutes but it is reset with every pageview. This means that is the visitors interacts with a website without a break, all his activity will be recorded within one session. However if the visitor stays inactive for more than 30 minutes, GA will set a new __utmb cookie the next time when he refreshes or reloads a webpage.
Let’s say for example that you visit my website at 10am. The __utmb cookie is set and GA registers one new session. You’re browsing the website and for one hour you have visited 10 pages. With every page view the expiration time of the cookie is reset with another 30 minutes. This means for this one hour you spent on my website GA has reported 10 pageviews and one new session.
At 11am you decide to take a shower but you leave your browser open on the webpage you’re about to read.
You return at 11:40am to continue your reading. 40 minutes has passed since the __utmb was reset for the last time. At the moment when the browser refreshes the webpage, a new _utmb cookie is set and your visit is recorded as a new session.
03. _utmz (Source/Campaign cookie) – This cookie is used to determine the traffic source, medium, campaign name and campaign term which sent the user to your website.
Basically, this cookies stores the
information about how the visitor reached your site: what search engine he
used, what link he clicked on, which add or social media post brought him.
The _utmz cookie is created when a visitor hits your site for the first time. This is important detail, because it helps to determine the original traffic sources that assist conversions.
Imagine a scenario where a visitor first finds your website on Google’s search results. He comes to your site. The _utmz cookie is created. He visits a few pages and leaves. After a few days (or weeks), the same visitor sees your website on an Adwards ad, clicks on the ad, lands on the website and this time he purchases your product.
Thanks to the information from the _utmz cookie, Google Analytics will attribute this conversion (the purchase) to the first channel that brought the visitor to your website: organic. The initial source will be Google.
The cookie is updated with each page view, and its The default expiration time of the _utmz cookie is 6 months, but the cookie is updated with each page view.04. _utmv (visitor segmentation cookie) – This cookie is used by GA to store visitor-level custom variable data (when the _setCustomVar method is used).
This cookie is set only on websites
that Custom user segment in GA.
Its default expiration time is 2 years and it is reset each time the user visits your site before the expiration of the cookie.
This cookie is set only on websites
that use Google Analytics Content Experiments (formerly the Website Optimizer).
When the Content Experiments script executes, it sets this cookie to record which version of the test has been assigned to this visitor.
It’s good to know that there’s one
more cookie which Google Analytics set on a visitor’s hard disk.
However the _utmc cookie is not used in ga.js. It is set for interoperability with the urchin.js library.
Historically, this cookie is operated in conjunction with the __utmb cookie to determine whether the user was in a new session/visit.
Universal Analytics use a new collection technology, different from the one used in Classic Analytics. The new version uses two collection methods: the analytics.js library and the Measurement Protocol.
Thanks to that, Universal Analytics is able to collect user interaction data without browser cookies.
The analytics.js library sets a single first-party cookie named _ga.
- _ga – This cookie stores a unique client identifier (Client ID) for every visitor of the website.
Once the client ID is generated (as
a random number) it is stored in the cookie and is included with each
hit/request that the website sends to Google Analytics.
This ID is later used by Google Analytics servers to calculate user, session, and campaign data.
By default, the _ga cookie is set to expire after 2 years but its expiration date is refreshed every time a hit is sent to GA (similar to the _utma cookie)
Urchin was the first iteration of the Google Analytics tracking code. When the newer ga.js library launched, developers were encouraged to migrate to the new library. Today most of the websites have already upgraded to the newer versions (ga.js or analytics.js).
For sites that haven not completed the migration, urchin.js sets cookies identically to what is set in ga.js.
We saw that the cookies have default
However, it is possible to customize the expiration time of some of these cookies according to your website needs. .
I will cover some of the possible cookies customizations in one of my next posts.