a) a visit's campaign information can't be viewed in a GA cookie anymore, and
b) session timeout information can be set within the GA Admin interface, as shown in the screenshot.
[original post follows]
This post contains information on how long Google Analytics uses cookies to track users. Cookies are a fundamental piece of how Google Analytics tracking works, so understanding them will greatly help in troubleshooting implementation issues or understanding reports on new vs returning visitors, traffic sources, etc.
Cookie Summary
Google Analytics has 3 main cookies: utma, utmb, and utmz. An older version of GA had a utmc session cookie, but this has been deprecated. There is also a utmv cookie for custom variables, but this post will focus on the 3 main cookies that you will see in every instance of GA.
The utma cookie, or "visitor" cookie has a 2 years expiration period. Each time a user comes to the site, their cookie gets updated for another 2 years.
The utmz cookie or "campaign" cookie has a 6 month expiration period. If a user comes back to the site within 6 months, it will remember the last traffic source of that visitor. It will typically be overwritten when a user comes back to the site after using a new traffic source, unless they come back as direct traffic (by typing in the URL, clicking on a bookmark,etc). In that case, the utmz cookie will still remember that they previously came from, say, an AdWords link and attribute their actions to AdWords.
The utmb cookie, or "session" cookie, has a 30 minute expiration period. If a user comes back to site within 30 minutes, it gets counted as part of the same session (as long as it's the same campaign source and the day hasn't changed).
See the below table for a summary of the above.
Cookie | Cookie Type | Expiration Period | Purpose |
utma | Visitor | 2 years | creates persistent ID to track visitors across multiple visits |
utmz | Campaign | 6 months | identifies which traffic source brought the user to the site |
utmb | Session | 30 minutes | ties together all page views and actions within a visit |
Cookie Customization
An interesting GA tweak is that the expiration period for each of these can be modified using GA's cookie timeout functions. There are a couple reasons users might want to do this:
1) users may want to change these settings to match their business rules. For example, their business may want to wait longer than a 30 minute period of inactivity before determining that a new session has started.
2) this can be used to match privacy policies, if certain local laws do not allow tracking users for extended periods of time or limit the length of expiration for these cookies.
The way to modify these settings is using the following 3 functions, which match to the above cookies as follows:
_utma cookie: _setVisitorCookieTimeout(enter_cookie_timeout_value_in_milliseconds)
_utmz cookie: _setCampaignCookieTimeout(enter_cookie_timeout_value_in_milliseconds)
_utmb cookie: _setSessionCookieTimeout(enter_cookie_timeout_value_in_milliseconds)
To use these functions, add them to the main tracking code block that goes on every page.
For more details please see https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration
Hello,
I was researching as to why I have utma, utmz cookies in my logs, even though I quit using analytics. It has been a week now, and I still observe those cookies. So, with expiration periods this long, it will be some time before they disappear?
But I am assuming these cookies belong to our domains, so they can be flushed by setting a new cookie that is expired.
Can I ask what logs you're referring to?
Super interesting, as a reference to share with clients about the cookie expiration. I just shared this post on my blog, thanks 🙂
Thanks, Cristian! Cool blog 🙂
I was searching for this topic from the past 2 days i have to make a thesis.Awesome work and great article .
There is a question if we add these codes in blogger along with the tracking code will they work do you prefer using all 3 of them or only one
_utma or _utmz
Hi Tayyab, all these cookies get set automatically, you don't need to do anything except make sure the basic GA tracking code is enabled.
Can we lengthen the time range in the time to purchase/ lat time report in analytics using any of these? I have a client with really long lag time between first visit to purchase (6-8 weeks), so 30 days is a bit useless to me.
Good question - you're right, 30 days is useless for quite a lot of businesses with a longer sales cycle, and for now there's no way to lengthen the time range. That means that the only way to handle this is to pass a visitor ID into a custom var for every visitor that hits your site (see http://cutroni.com/blog/2011/05/05/merging-google-analytics-with-your-data-warehouse/ for more details) and do your own user-level analysis.
Alternately you can wait and hope that GA upgrades this functionality soon - they do make tons of updates to the product so anything is possible.
So am I right in thinking this customization of the UTMA cookie means that it is possible to improve your unique visitors figure? I'm surprised if this isn't exploited by many.
Interesting comment. There are a few ways you could change your unique visitor count - I see overstated visit/visitor counts regularly - but so far it's always been due to broken code, not on purpose! I think most companies are using GA to understand their business, not produce an inflated number. Your point may be that some advertising rates are based on visitor counts but advertisers wouldn't continue advertising if they didn't get the results they expected, right? I don't know, can you elaborate on how you might exploit the system? 🙂