How Google Analytics Uses Cookies


Certain reports in Google Analytics rely heavily on cookies. If a visitor deletes or blocks their cookies, information for that visit or visitor will be misinterpreted or lost.

Unique Visitors

Cookies are a major component of unique visitor tracking. They tie all the activity of a visitor into a single visit, and are used to determine when a visit ends.

Activity

Cookies store vital information about each visit. They store the start time of the current visit and keep track of how many pages have been viewed so far. If a visitor closes the browser or is inactive for too long, the cookies will indicate that the visit has ended.
Cookies store the date and time of the visitor’s first visit (allowing for calculations of how many visits it took to convert). The total number of visits from the visitor is stored in cookies, too.

Traffic Source

Cookies are the main vehicle for attributing visit information and conversions to specific marketing campaigns or traffic sources. Each time the visitor comes to the site, the code stores new referral or campaign variable information in the visitor’s cookies.

 

Dissecting Google Analytics Cookies


Google Analytics uses several cookies to record all of this information. The most common are covered here.
All of the cookies store a domain hash that ties them to the same site. In the case that cookie information changes during a visit (e.g., a user-defined variable gets changed from “Prospect” to “Customer”), Google Analytics will attribute the entire visit to the last cookie value.

__utma
This is the main way Google Analytics tracks unique visitors. Stored in this cookie is a unique visitor ID, the date and time of their first visit, the time their current visit started and the total number of visits they have made.

__utma
This cookie is a persistent cookie that expires in two years. With each new visit, the expiration date is refreshed.
.
__utmb
This is how Google Analytics decides whether a visit has timed out and also how deep a visit has gotten. It stores the number of pageviews in the current visit and the start time of the visitor’s current visit. The __utmb cookie is a persistent cookie that expires in 30 minutes. Each pageview refreshes it. The expiration time can be customized for each site (or page). Our code generator tool can automatically customize that code.

__utmc
This cookie is the only session cookie used by Google Analytics. Its only purpose is to register that the visit ended if the browser gets closed.

__utmz
This is the traffic source cookie. It contains all of the traffic source information for the current visit, if it was different from the previous visit. If no traffic source information can be found for the current visit, the cookie is not changed. This is the way that Google Analytics attributes visit information, including conversions and transactions to a traffic source. It does not contain historical information for previous sources.

This is a persistent cookie with a catch: it expires in six months and is only refreshed when the traffic source changes. Every other cookie is refreshed with each page view. The impact of this is that a banner ad that brings a visitor to your site will get the credit for all future direct visits for up to six months. After six months, if there have not been visits from any other source, the cookie will expire and start to attribute information to direct visits.

__utmv
This is the user-defined variable cookie. Developers can segment visitors by custom variables by calling a native JavaScript method. This new variable gets stored in a persistent cookie which expires in two years.