For the next few posts I will be answering the questions I am frequently asked about various issues in Google Analytics. Instead of replying to the individual emails I thought of addressing all the issues in one go and at the same time share my understanding of Google analytics with others. This post is the first in the series. You should have a good knowledge of cookies so that you can understand how Google Analytics collect data, how it define visits, visitors and other metrics.
What is a Cookie?
Cookie is a text file which is used to store information about a visitor, his preferences, location and other details.
How websites that run Google Analytics are able to track unique Visitors?
They are able to track through first party cookies. Websites that run Google Analytics (GA) issue first party cookies which are stored on visitor’s hard disk. So when a visitor returns to a website that runs GA, the website is able to remember the visitor through the cookies set up on his hard disk. In this way Google Analytics doesn’t count the returning visitor as a new visitor.
What are the different types of cookies?
There are two types of cookies:
- First Party Cookies
- Third Party Cookies
First party cookies are issued by the website being visited and only the website which issued the first party cookie can read the cookie. Third party cookies are issued by the website(s) other than the website being visited.
Which types of cookies are used for Google Analytics tracking?
Google Analytics uses First party cookies.
Can a visitor disable some or all types of cookies?
Yes.
Can cookies be set with or without expiration date?
Yes.
What is the difference between persistent and temporary cookies?
Persistent cookies are the cookies with expiration date. They remain on your computer even when you end the web session or close your browser window. They can be read by the website that created them on return visits. Temporary cookies are cookies without expiration date. They expire as soon as you end the web session or close the browser window.
Can we determine exact number of visitors who have cookies enabled or disabled?
No.
Which websites can read your Google Analytics Cookies?
Only your website can read the cookies set by it and no other website. This is because Google Analytics cookies are first party cookies.
Which first party cookies are set by Google Analytics on my visitor’s hard disk?
Google Analytics can set following five first party cookies:
- _utma (unique visitor cookie)
- _utmb (session cookie)
- _utmz (Campaign cookie)
- _utmv (visitor segmentation cookie)
- _utmx (Google Website Optimizer cookie)
Note: There is one more cookie which Google Analytics set on a visitor’s hard disk. This cookie is known as _utmc cookie. Google Analytics doesn’t use this cookie any more to determine session status (if you are using ga.js tracking code).
Which Google Analytics Cookies are persistent and which are temporary?
All of the Google Analytics cookies are persistent except the _utmc cookie which is a temporary cookie.
When _utmv cookie is set up by Google Analytics on a visitor’s hard disk?
This cookie is set up only when Google Analytics tracking code call the _setCustomVar() method (in case of ga.js).
When the Google Analytics cookies expire?
i) _utma – this cookie expires after 2 years from the last time your visitor visited the site.
ii) _utmv – this cookie expires after 2 years from the last time your visitor visited the site.
iii) _utmx – this cookie expires after 2 years from the last time your visitor visited the site.
iv) _utmb- this cookie expires after 30 minutes from the last time your visitor visited the site or at the end of a day.
v) _utmc – this cookie expires as soon as you close the browser window
vi) _utmz – this cookie expires after 6 months from the last time your visitor visited the site.
How I can view the various cookies set up by Google Analytics when I visit a website?
Step-1: Install web developer toolbar in Firefox or use your favorite tool to view cookie information.
Step-2: Go to the website which has installed Google Analytics Tracking code on its web pages.
Step-3: Click on the cookies menu from the ‘web developers’ toolbar and then select ‘view cookie information’ as shown in the image below:
You can now see the cookies set up by Google Analytics on your hard disk:
Note: You can use the above method to see all the cookies (not just Google Analytics cookies) set up by a website on your hard disk.
Does Google Analytics set different set of cookies when I return to a website via another web browser?
Yes. This is because all cookies are browser specific.
When cookies are created /set up by Google Analytics?
Cookies are created as soon as you visit a website.
Through which cookie Google Analytics is able to indentify unique visitors?
Through _utma cookie.
How I can interpret the _utma cookie?
Domain Hash => This number represents the domain which set up the cookies. All Google Analytics cookies set by a particular domain have same domain hash.
Random Unique ID => This is the second number which is randomly generated.
The next three numbers are timestamps which represent the time of initial visit, beginning of previous session and beginning of current session. All these three numbers also represent the number of seconds elapsed since Jan 1, 1970.
The last number is the session counter. It is incremented each time a visitor starts a new session.
How Google Analytics define visitor as unique?
Google analytics assign unique ID to each visitor on your website. This ID is called the visitor ID and it is made up of random unique ID and the first time stamp (also known as the time of initial visit).
Note: If you look at the three timestamps above, you will notice that they all are same.
What does all the same timestamps in the _utma cookie tells you?
It tells you that this is your first visit to the website.
How I can reset my session counter in _utma cookie to 1?
You can do this by deleting all the Google Analytics cookies or by using a different web browser or computer to return to a website.
Can I change the expiration date of _utma cookie?
Yes through _setVisitorCookieTimeout() method. This method is used to change the expiration date of _utma cookie. By default, _utma cookie expires after 2 years. But you can set it to expire after 1 week or any time you want to. For example:
_gaq.push([‘_setVisitorCookieTimeout’, 604800000]);
Here _setVisitorCookieTimeout() method sets _utma cookie to expire after 1 week.
Note: Use a search query like ‘1 week in milliseconds’ on Google to convert any time into milliseconds.
Can I set the _utma cookie to expire as soon as the browser window is closed?
Yes. For this set the expiration timeout of the _setVisitorCookieTimeout() method to 0. For e.g.
_gaq.push([‘_setVisitorCookieTimeout’, 0]);
Through which cookie Google Analytics is able to identify a web session?
Google Analytics uses _utmb cookie to identify a web session. When your visitor loads a web page, the Google analytics tracking code check for _utmb cookie on the visitor’s hard disk. If this cookie is missing then Google Analytics treats the session as a new session and creates a new _utmb cookie. If the cookie is already present than Google Analytics update the cookie to expire in 30 minutes.
Note: Web session is also known as visit.
When Google Analytics end a web session?
A web session ends when _utmb cookie is destroyed. This cookie is automatically destroyed after 30 minutes of its setup. If a visitor stays on a web page for more than 30 minutes, the _utmb cookie is automatically destroyed and the current web session automatically expires. If later the same visitor reloads the web page or navigates to other page of the website, Google Analytics starts the new session. As long as the visitor’s activity continues on your website within 30 minutes interval, the _utmb cookie will not be destroyed even if the visitor closes the browser window or navigate to web pages of other websites within the 30 minutes time frame.
The _utmb cookie is also destroyed at the end of a day or when a visitor returns to the website via a different traffic source value (utm_source, utm_medium, utm_campaign, utm_content, utm_term, utm_id or gclid) even within the 30 minutes time frame. For example if a visitor come to your website via a PPC ad and then later return to the website via organic search listing then his second visit will start a new web session even if 30 minutes have not elapsed between the two page views/visits.
How a web session can be longer than 30 minutes when _utmb cookie expires after 30 minutes?
Whenever a visitor navigates to other page of a website, Google Analytics updates the _utmb cookie to expire after 30 minutes. So as long as the visitor doesn’t stay on a web page for more than 30 minutes and continue to navigate other pages of the website, the _utmb cookie will not expire and hence the web session will not terminate.
How I can interpret the _utmb cookie?
Can I change the session time out length (which is usually 30 minutes) to anything I want?
Yes you can. Use the _setSessionCookieTimeout() method in your Google Analytics tracking code. This method is used to specify when the session should time out in milliseconds.
1 millisecond = 0.001 seconds
Syntax: _gaq.push([‘_setSessionCookieTimeout’, 100000]);
Here you are telling Google Analytics to end a web session in 100 seconds.
Note: Avoid using this method as it can considerably increase or decrease the number of visits reported by Google Analytics. It can also skew all those metrics which use visits in its calculations.
Can I set the _utmb cookie to expire as soon as the browser window is closed?
Yes. For this set the expiration timeout of the _setSessionCookieTimeout() method to 0. For e.g.
_gaq.push([‘_setSessionCookieTimeout’, 0]);
What is _utmz cookie?
It is a campaign cookie which is used by Google Analytics to store campaign information. The campaign information is stored in campaign variables. Following are the campaign variables supported by Google Analytics:
- utm_source
- utm_medium
- utm_campaign
- utm_term
- utm_content
How I can interpret the _utmz cookie?
The first number in the _utmz cookie is the domain hash which represents the website that set up the cookie on visitor’s hard disk. The second number is a timestamp. The third number is the session number which is incremented every time a visitor starts a new session. For example: from the image above we can see that this is the 8th session of the visitor.
Note: For every new session that campaign cookie values gets overwritten with new value.
The fourth number in the _utmz cookie is the campaign number. This number is incremented every time a visitor arrives at your website via a different campaign even within the same session. From the image above we can see that the visitors arrived on my website via 6 different campaigns.
The last number in the _utmz cookie contains information about the campaign which resulted in the current visit.
utmcsr = >It represents campaign source and stores the value of utm_source variable. For example, from the image above we can see that the campaign source for the current visit is Google.
utmccn = >It represents campaign name and stores the value of utm_campaign variable. For example, from the image above we can see that the campaign name for the current visit is organic.
utmcmd = >It represents campaign medium and stores the value of utm_medium variable. For example, from the image above we can see that the campaign medium for the current visit is organic.
utmctr = >It represents campaign term (keyword) and stores the value of utm_term variable. For example, from the image above we can see that the campaign term for the current visit is seotakeaways.
utmcct = >It represents campaign content and stores the value of utm_content variable.
So in short the visitor clicked on my search engine listing for the keyword ‘seotakeaways’ via Google Organic search. Once Google Analytics read the _utmz cookie it sends the campaign information to the Google Analytics server which then sends the data to analytics reports.
How the content of the campaign cookie _utmz will look like if I visit the following URL:
http://www.seotakeaways.com/?utm_source=bing&utm_medium=ppc&utm_term=web-analytics&utm_content=st-brand-1&utm_campaign=brand
The campaign cookie will look like this:
How I can see the campaign information collected by _utmz cookie in my Google Analytics reports?
Check the ‘All traffic sources’ report or ‘campaigns’ report (not the Google Adwords campaigns report) in your Google Analytics reports.
The _utmz cookie has a 6 months time out. What does that means?
It means Google Analytics attribute visit to a campaign for up to 6 months or until the campaign cookie value is overwritten with another value.
Can I change the campaign cookie time out length?
Yes you can. Use the _setCampaignCookieTimeout() method in your Google Analytics tracking code. This method is used to specify when campaign cookie expiration should time out in milliseconds.
1 millisecond = 0.001 seconds
Syntax: _gaq.push([‘_setCampaignCookieTimeout’, 100000]);
Here you are telling Google Analytics to delete the campaign cookie (_utmz) after 100 seconds.
Can I set the _utmz cookie to expire as soon as the browser window is closed?
Yes. For this set the expiration timeout of the _setCampaignCookieTimeout’ () method to 0. For e.g.
_ gaq.push([‘_setCampaignCookieTimeout’, 0]);
What is custom/user defined visitors segmentation in Google Analytics?
Visitor segmentation is used to label your visitors as male, female, member, non member, signed in or signed out visitors etc.
What is _utmv cookie and how can I set it on a visitor’s hard disk?
This is a visitor segmentation cookie which is used by Google Analytics to identify a visitor as member, non-member, pro-member, pro++ member, male, female, employee, non-employee etc.
To set this cookie you need to use the _setCustomVar() method in your Google Analytics tracking code.
Syntax: _setCustomVar(index, name, value, opt_scope)
Example: _gaq.push([‘_setCustomVar’, 1, ‘visitor-type’, ‘pro-member’, 3]);
How I can interpret _utmv cookie?
From the cookie above we can determine that the visitor is a pro member.