Google Analytics cookies: _ga cookie, _utmb, _gat – Tutorial

Last Updated: May 24, 2022

If you really want to understand how Google Analytics: collects data, defines usersdefines sessions, defines metrics and/or if you want to implement cross-domain tracking, cross-device tracking or any other specialized tracking in GA, then you need to develop a good great understanding of cookies.

Introduction to Cookies

A cookie is a text file that is used to:

  • Store information about user preferences, user location, and other details
  • Protect users’ data from unauthorized access
  • Maintain certain websites’ functionality
  • Serve personalize ads to users and make advertising more effective via re-marketing
  • Collect Google Analytics data and other tracking data.

Cookies are stored on a user’s hard disk and can be enabled or disabled via web browser settings.

Cookies are nothing but a piece of code saved by the websites onto the user’s web browsers when a session is initiated. As mentioned above, they have many uses, but the most important ones are session management, user personalization, and tracking.

Cookies are not programs; they do not perform any function. For example, if a user visits a website, that website’s cookie is dropped on the user’s browser. When the users visit the website again after a few days, the website will know that it was the same user.

With the EU cookie policy in place, every website owner must now seek the user’s consent before dropping any cookies in their browser. Users have all the rights to opt-in or opt-out of the cookies, and they also have the capability to opt-out of specific cookies as well (For example, opting out of marketing cookies).

Note: You cannot determine the exact number of users who have cookies enabled/disabled.

Types of Cookies

There are two types of cookies:

#1 First-Party Cookies – These cookies are issued by the website being visited, and only the website which issued the first-party cookies can read them.

The data collected by these cookies is used mainly for calculating sessions, pageviews, bounce rate and other metrics.

As an example of the first party cookie, when a user signs into an ecommerce website, the web browser will send a request in a process that provides the highest level of trust that the user is directly interacting with the main website. The website drops a cookie into the user’s browser under the same domain name.

#2 Third-Party Cookies – These cookies are issued by the website(s) other than the website being visited. For example, say you have visited an online shopping website and spent

some time on the product purchase page and did not make a purchase. Later, you would receive emails about a price drop for the same product that you looked at. These are shown to the user by remarking pixels placed on the page.

Cookies With and Without Expiration Date

Cookies (both first and third-party cookies) can be set with or without an expiration date.

The cookies set without expiration date are known as temporary cookies. Such cookies expire when you end the web session or close the browser window.

The cookies set with an expiration date are known as persistent cookies. Such cookies expire only on the expiration date and can remain on your computer even when you have ended the web session or closed your browser window.

Apart from this, you also have secure cookies. Only an HTTPS website can set these cookies. It is mostly ecommerce websites with checkout pages that redirect to payment gateways with secure cookies to make transactions safe and secure. Banking websites also use secure cookies.

Note: All Google Analytics cookies are persistent except the _utmc cookie, which is a temporary cookie.

Cookies Set By Google

Google sets different types of cookies for different purposes.

Following are the type of cookies set by Google on a user’s hard disk:

  • Preference cookie (called PREF) – used to store users’ preferences (like preferred language or any type of customization).
  • Security cookies (like ‘SID’ and ‘HSID’) –  used to protect users’ data from unauthorized access.
  • Process cookies (like ‘lbcs’) – used to maintain certain websites’ functionality
  • Advertising cookies (like ‘id’) – used to serve personalized ads to users and to make advertising more effective
  • Conversion cookies – used to track users’ interaction with ads.
  • Analytics cookies (like _utma, _utmb, _ga, etc.) – used to collect Google Analytics data.

Google Analytics and Cookies

Google Analytics sets cookies to:

  • Identify unique users
  • Identify unique sessions
  • Throttle the request rate
  • Store information about users’ sessions and campaigns.

Google Analytics mainly sets first-party cookies. But it can also set third-party cookies (DoubleClick cookies) if a website uses GA display advertiser features, such as re-marketing.

Cookies and JavaScript Libraries

Google Analytics uses cookies based on the JavaScript library being used.

Google Analytics has got three types of JavaScript libraries for tracking website usage data:

  1. urchin.js (the oldest version of GA tracking code, now deprecated)
  2. ga.js (used in Classic Google Analytics)
  3. analytics.js (used in Universal Analytics)

Google Analytics Cookies are created as soon as you visit a website on which a valid Google Analytics tracking code is installed and is fired.

Since all cookies are browser-specific, Google Analytics will set a different set of cookies if you return to a website via another web browser. If a GA cookie already exists, it is updated to collect users’ data. So if you try to create a cookie that already exists, it will be overwritten.

Note: Google Analytics does not store and does not allow any personally identifiable information in its cookies.

analytics.js Cookies (Cookies used by Universal Analytics)

The analytics.js JavaScript library sets the following first-party cookies:

#1  _ga cookie – used to identify unique users and expires after two years.

#2  _gat cookie – used to throttle the request rate, and it expires after one minute. If Google Analytics is set up using GTM, this cookie is set as  _dc_gtm_<property-id>.

#3  _gid – used to identify the user and expires in 24 hours

These cookies are set on the top-level domain so that users can be automatically tracked across subdomains without any extra configuration.

Understanding Top-Level Domains

The top-level domain is the highest domain level.

For example, in the case of the following domains:

  1. www.abc.com
  2. music.abc.com
  3. asian.music.abc.com

The highest domain level is abc.com. So the top-level domain is abc.com

The second highest domain levels are: www.abc.com and music.abc.com

The third highest domain level is asian.music.abc.com

Note: Ideally, ‘.com’ should be the highest domain level. But Google Analytics can not set up a cookie at ‘.com’ level.

Creating analytics.js Cookies

To create analytics.js cookies,  you need to create a tracking object using the ‘create’ command.

Syntax: ga(‘create’, ‘UA-XXXX-Y’,’auto’);

Note: Universal Analytics (UA) can also collect data even without any cookies through the measurement protocol.

Viewing analytics.js Cookies

The analytics.js cookies are set as soon as a user loads your web page in his browser (provided the web page contains valid universal analytics tracking code and it fires on page load).

To view the analytics.js cookies, follow the steps below:

Step-1: Visit a web page that contains valid universal analytics tracking code in your Chrome browser.

Step-2: Click the Chrome menu button on the browser toolbar and then select Settings:

ga cookies chrome settings

Step-3: Scroll down the page, and then at the bottom, click on the ‘Advanced’ drop-down menu:

ga cookies advanced settings

Step-4: Click on the ‘content settings’ button:

ga cookies content settings

Step-5: Click on the ‘Cookies’ button:

ga cookies cookies button

Step-6: Scroll down the page and search for the ‘Search Cookies’ text box:

ga cookies search cookies search

Step-7: Search for the domain name whose web page you visited in step-1 and then click on the button like the one below:

ga cookies all cookies and site data 1

You can now see the various cookies set by the website, including the analytics.js cookie _ga:

ga cookies cookies set by domain

Step-8: Click on ‘_ga‘ cookie to see more details about the cookie:

ga cookies click ga cookie 1

You can now see all the details about _ga cookie:

ga cookies ga cookies detail 1

From the screenshot above, we can conclude that the _ga cookie is made up of the following four fields:

ga cookies ga cookie3

First field is the version number (GA1). It seems to be fixed at the moment and may change if the cookies format changes in the future.

The second field is number of components at the domain separated by dot. By default the _ga cookie is set on the top level domain with the root level (/) path.

The third field is random unique ID (randomly generated number).

The fourth field is first time stamp i.e. the time when the cookie was first for the user or the time when a user first visit the website.

The third and fourth field together make, what we called the client ID:

ga cookies ga cookie2

Cookies and Client ID

Google Analytics identifies unique users across GA sessions through client ID.

The client ID is stored in the Google Analytics cookie. The GA cookie is set when a person visits your website for the first time. Google Analytics sends the client ID with each hit to associate hits with a user.

A GA cookie can exist only on the device and browser where it has been set. Since client ID is stored in a GA cookie, the client ID will also exist only on the device and browser where it has been set. Because of this reason, by default, GA can’t identify unique users across different web browsers and devices.

Also, note that cookies are site-specific. The default Google Analytics implementation will track the subdomain user’s activity. If a user travels between the site and the subdomain, they will still maintain the same cookie. However, cross-domain tracking is different; cookies will not be shared unless you have set up cross-domain tracking correctly on your website.

If you want to retrieve the client ID from _ga cookie then use the following call back function:

ga(function(tracker) {
var clientId = tracker.get(‘clientId’);
});

If you want to collect client IDs in GA reports, then you can do that by creating a new custom dimension with user scope:

ga(‘set’, ‘dimension1’,clientId);

Identifying unique users across different web browsers and devices is known as ‘Cross-Device Tracking’.

If users can log in on your website, then you can implement cross-device tracking with the help of User ID.

Cookies and User ID

User ID is a unique random number used to uniquely identify users across different web browsers and devices.

According to Google terms of service, the User ID must not contain any personally identifiable data like the user’s name, email address, etc. User ID is different from client ID in that client ID is generated by Google Analytics. Whereas a User ID is generated by your users’ authentication system (like Website Login).

To send user ID data to Google Analytics, use the ‘set’ command method like the one below:

ga(‘set’, ‘userId’, ‘USER_ID’);

here, the value of USER_ID is of type string. For example:

ga(‘set’, ‘userId’, ‘DTS234554134’});

You can also send user ID data to GA, while creating the tracking object:

ga(‘create’, ‘UA-XXXX-Y’, ‘auto’,{ ‘userId’: ‘USER_ID’ });

For example,

ga(‘create’, ‘UA-XXXX-Y’, ‘auto’,{ ‘userId’: ‘DTS234554134’});

There are two important points that you need to remember about using user IDs:

#1 The user IDs must be set after the tracking object has been created. Otherwise, the user IDs will not be associated with your web property.

So the following user ID set-up will not work:

ga(‘set’, ‘userId’, ‘USER_ID’); // user id is set before the tracking object

ga(‘create’, ‘UA-XXXX-Y’,’auto’); // create a tracking object

The correct set-up should be like the one below:

ga(‘create’, ‘UA-XXXX-Y’,’auto’); // create a tracking object
ga(‘set’, ‘userId’, ‘USER_ID’);

or

ga(‘create’, ‘UA-XXXX-Y’,’auto’,{‘userId’: ‘USER_ID’});

#2 The user IDs must be set before you send any hit data to GA. Otherwise, user IDs won’t be set for all subsequent hits that occur on a page.

So the following user ID set-up is not recommended:

ga(‘send’, ‘pageview’);

ga(‘set’, ‘userId’, ‘USER_ID’); // here user id is set after the pageview hit

The correct set-up should be like the one below:

ga(‘set’, ‘userId’, ‘USER_ID’); // here user id is set before the pageview hit

ga(‘send’, ‘pageview’);

If you want to collect user IDs in GA reports, then you can do that by creating a new custom dimension with user scope:

ga(‘set’, ‘dimension1’,userId);

Note: You can also set up user IDs for mobile apps.

_ga cookie has got the following attributes:

  1. Cookie name
  2. Cookie domain
  3. Cookie path
  4. Cookie expires

You can modify _ga cookie by changing its attributes.

Note: Google recommends not to directly access the _ga cookie as the cookie format might change without warning, which could lead to script errors and incorrect data.

The cookie name is the name of the google analytics cookie, which is _ga by default. If you want to change this cookie name to something else, you can do this by setting the cookieName field. For example:

ga(‘create’, ‘UA-12345-1’, {‘cookieName’: ‘optimizesmart’});

The cookieName field accepts values of type text.

Cookie domain is the domain at which the Google Analytics cookie _ga is set up.

By default, the cookie is set on the top-level domain. So, if you set a cookie at the top-level domain like www.optimizesmart.com, the cookie domain would be ‘optimizesmart.com’.  (without ‘www.’ Prefix).

If you want to set _ga cookie at the sub-domain level like music.optimizesmart.com, then set the cookieDomain field as:

ga(‘create’, ‘UA-12345-1’, {‘cookieDomain’: ‘music.optimizesmart.com’});

If you want to set _ga cookie at the sub-sub-domain level like asian.music.optimizesmart.com, then set the cookieDomain field as:

ga(‘create’, ‘UA-12345-1’, {‘cookieDomain’: ‘asian.music.optimizesmart.com’});

Note: The cookieDomain field accepts values of type text.

The cookie domain needs to be an ancestor of the current domain.

In the case of cross-domain tracking, the cookie domain needs to be an ancestor of the current domain.

For example, if the current domain is www.abc.com, you can set the cookie at abc.com as abc.com is the ancestor of www.abc.com. But you can’t set a cookie at music.abc.com because it is not the ancestor of www.abc.com.

Similarly, you can’t set a cookie on some other website like ‘example.com’ because it is not the ancestor of www.abc.com.

Note: When you set an incorrect value for cookieDomain, the _ga cookie is not set.

Setting cookies on localhost.

If you want to set _ga cookie on localhost, then set the value of cookieDomain to ‘none’. For example:

ga(‘create’, ‘UA-12345-1’, {‘cookieDomain’: ‘none’});

Automatic cookie domain configuration

If you want google analytics to automatically determine and set the _ga cookie at the top-level domain or automatically set the value of cookieDomain to ‘none’ when you use localhost, then use ‘auto’ as the value of cookieDomain.

For example:

ga(‘create’, ‘UA-12345-1’, {‘cookieDomain’: ‘auto’});

You can also write this line of code as:

ga(‘create’, ‘UA-12345-1’,‘auto’);

The advantage of using an automatic cookie domain configuration is that you can track users across all sub-domains without any additional configuration.

Cookie Path is the path at which the cookie is set up.

The _ga cookie is set on the top-level domain with the root level (/) path by default. If you want to modify the _ga cookie path from the default ‘/’ to say ‘/lib’, then set the ‘cookiePath‘ field to ‘/lib’:

ga(‘create’, ‘UA-XXXX-Y’, {‘cookiePath’: ‘/lib/’});

Note: Google does not recommend changing the cookie path.

Cookie Expires is the time in seconds after which the _ga cookie will expire.

By default, a _ga cookie expires after two years from the date it was last refreshed. Every time a new hit is sent to google analytics, the cookie is refreshed.

You can set your own cookie expiration time by using the cookieExpires field:

ga(‘create’, ‘UA-12345-21’, {‘cookieExpires’: 180});

Here we set the _ga cookie to expire after 180 seconds.

Note: The cookieExpires field accepts values of type integer.

Making  _ga cookie a ‘browser session’ based cookie

If you set the _ga cookie to expire after 0 seconds, then the cookie turns into a browser session-based cookie and expires once the current browser session ends. For example:

ga(‘create’, ‘UA-12345-21’, {‘cookieExpires’: 0});

Note: The biggest drawback of the _ga cookie is that you can’t dig out session or campaign-specific data from the cookie as all of these calculations happen in the backend on GA servers.

Disabling analytics.js Cookies

If you want to use your own storage mechanism and send data directly to Google Analytics without using cookies then:

#1 You need to set the ‘storage’ field to none

#2 Supply your own client ID

For example,

ga(‘create’, ‘UA-XXXX-Y’, {

‘storage’: ‘none’,

‘clientId’: ‘35009a79-1a05-49d7-b876-2b884d0f825b’

});

Deleting analytics.js Cookies

ga cookies delete cookies 1

You can delete cookies through Chrome settings:

Once you delete the analytics.js cookies, returning users will be treated as new users.

However, there is no guarantee that the returning will always be treated as new users because analytics.js does not always rely on the _ga cookie for collecting data, especially when the measurement protocol is being used.

The ga.js JavaScript library sets the following first-party cookies:

  1. _utma (unique visitor cookie)
  2. _utmb (session cookie)
  3. _utmc (session cookie)
  4. _utmt
  5. _utmv (visitor segmentation cookie)
  6. _utmx (Google Analytics Content Experiment cookie)
  7. _utmz (Campaign cookie)

By default, the ga.js JavaScript library sets these cookies on the domain specified in the document.host browser property.

To create ga.js cookies, you need to create a tracking object:

_gaq.push([‘_setAccount’, ‘UA-XXXXX-y’]);

Viewing ga.js Cookies

To view the ga.js cookies, follow the steps below:

Step-1: Visit a web page that contains valid Classic Google Analytics tracking code in your Chrome browser.

Step-2: Follow the steps you followed earlier for viewing the analytics.js cookies.

Step-3: Search for the domain name whose web page you visited in step-1. You can now see the various cookies set by the website, including the ga.js cookies:

ga cookies ga js cookies 1

Step-4: Click on one of the ga.js cookies to see more details about the cookie.

This cookie is used to identify unique visitors. It expires two years from the date it was last refreshed. Every time a new hit is sent to Google Analytics, the cookie is refreshed.

It is a persistent cookie, which means it remains on the user’s browser until it expires or the user clears the cache.

This cookie generates the client ID for the unique user. For example, if a user visited your website on March 15th, this cookie will set up a client ID in their browser. When the user returns to the website, say on March 20th, GA will look for this cookie. If this cookie already exists, then it understands that it is a returning visitor to the site.

In addition to assigning a unique identification to each of your visitors, the __utma cookie records the time and date of the first visit, the total number of visits, and the start time of the current visit.

Here is what this cookie looks like:

ga cookies 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.

Timestamps => 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.

Session Counter => The last number is the session counter. It is incremented each time a visitor starts a new session.

Google Analytics assigns a unique ID to each visitor to your website. This ID is called the visitor ID, and it is made up of a random unique ID and the first timestamp (also known as the time of initial visit):

ga cookies utma cookie2

If you look at the three timestamps above, you will notice that they all are the same numbers which means that this is your very first visit to the website.

Note: If you want to reset your session counter in _utma cookie to 1, you can do that by deleting all of the Google Analytics cookies or using a different web browser/device to return to your website.

This cookie is used to identify a web session and store information about the session. Google Analytics ends the web session when this cookie has expired. This cookie basically records the number of page views visited by the user in that session and captures each visit’s start time.

When your visitor loads a web page, the Google Analytics tracking code checks for the _utmb cookie on the visitor’s hard disk. If this cookie is missing, Google Analytics treats the session as a new one and creates a new _utmb cookie. If the cookie is already present, Google Analytics updates the cookie to expire in 30 minutes.

The _utmb cookie expires 30 minutes after the last refreshed date.

Every time a new hit is sent to google analytics, the cookie is refreshed. Because of this reason, a web session can last longer than 30 minutes, even when the _utmb cookie expires after 30 minutes. For example:

Whenever a visitor navigates to another website page, 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 continues to navigate other website pages, the _utmb cookie will not expire, and hence the web session will not terminate.

The _utmb cookie can also expire if a visitor returns to your 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 comes to your website via a PPC ad and then later returns to the website via an organic search listing, his second visit will start a new web session, even if 30 minutes have not elapsed between the two page views/visits.

Note: _utmb cookie does not expire if the visitor closes the browser window or navigates to other websites within the 30 minutes time frame.

Here is what this cookie looks like:

ga cookies utmb cookie

Note: The _utmb cookie expires at the end of a day.

The _utmc cookie is not used by ga.js anymore but is still set on a user’s hard disk for interoperability with urchin.js. Historically this cookie worked with the _utmb cookie to identify a web session.

The_utmb cookie basically captures the exact arrival time of the user on the website, and the _utmc cookie registers the exit time of the user. This cookie gives you information about how visitors have accessed your website. Have they entered the URL of your website directly into your browser, or have they clicked on any link somewhere on your site?

The _utmc cookie expires as soon as you close the browser window.

The _utmt cookie is used to throttle the request rate, and it expires after 10 minutes. It works just like _gat cookie.

This is a visitor segmentation cookie used by Google Analytics to identify a visitor as male, female, member, non-member, signed in or signed out visitors, pro-member, pro++ member, 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]);

This cookie expires after 2 years from the date it was last refreshed. Every time a new hit is sent to google analytics, the cookie is refreshed.

Here is what the _utmv cookie looks like:

ga cookies utmv cookie

From the screenshot above, we can conclude that the visitor is a pro member.

Note: _utmv cookie is set up by Google Analytics on a visitor’s hard disk only when Google Analytics tracking code call the _setCustomVar() method and the javascript library used is ga.js.

The _utmx cookie is a Google Analytics Content Experiment cookie used for A/B testing of different versions of a web page.

This cookie expires 18 months from the date it was last refreshed. Every time a new hit is sent to google analytics, the cookie is refreshed.

This is a campaign cookie used by Google Analytics to store campaign information, and it expires six months from the date it was last refreshed.

This cookie captures the HTTP referrer and notes where the visitor has arrived from with the referrer information (cpc, organic, direct, social). It also captures what keyword has generated the visit, including the geolocation.

The campaign information is stored in campaign variables.

Following are the campaign variables supported by Google Analytics:

  1. utm_source
  2. utm_medium
  3. utm_campaign
  4. utm_term
  5. utm_content

Here is what the _utmz cookie looks like:

ga cookies utmz cookie

Domain Hash – The first number in the _utmz cookie is the domain hash representing the website that sets up the cookie on the visitor’s hard disk.

Timestamp – The second number in the _utmz cookie is a timestamp.

Session Number – The third number in the _utmz cookie is the session number incremented every time a visitor starts a new session. For example, from the screenshot above, we can see that this is the 8th session of a visitor.

Note: For every new session, the campaign cookie values get overwritten with the new value.

Campaign number – 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 screenshot above, we can conclude that the visitors arrived on the website via six different campaigns.

Campaign Tracking values –  The last field 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 screenshot above, we can conclude 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 screenshot above, we can conclude 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 screenshot above, we can conclude 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 screenshot above, we can conclude that the campaign term for the current visit is seotakeaways.

utmcct = >It represents campaign content and stores the value of utm_content variable.

In short, a visitor clicked on a search engine listing for the keyword ‘seotakeaways’ via Google Organic search.

Note: Once Google Analytics reads the _utmz cookie, it sends the campaign information to the Google Analytics server, which then sends the data to analytics reports.

This cookie lasts “forever”. It is a persistent cookie. It is used for segmentation and data experimentation, and  _utmv works hand in hand with the   __utmz cookie to improve cookie targeting capabilities.

Q How the content of the campaign cookie _utmz will look like if you visit the following URL:

https://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:

google analytics cookies

Note: To see the campaign information collected by the _utmz cookie in your Google Analytics reports, check the  ‘campaigns’ report under the ‘Acquisition’ menu (not the Google Adwords campaigns report) in your Google Analytics account.

Attributes of ga.js Cookies

ga.js cookies have got the following attributes:

  1. _setDomainName
  2. _setCookiePath
  3. _setVisitorCookieTimeout
  4. _setSessionCookieTimeout
  5. _setCampaignCookieTimeout

You can modify ga.js cookies by changing these attributes.

#1 _setDomainName()

This method sets the domain at which all the ga.js cookies will be set.

By default, the cookie is set on the top-level domain. So, if you set cookies at a top-level domain like www.optimizesmart.com, the cookie domain would be ‘optimizesmart.com’.  (without ‘www.’ Prefix).

If you want to set ga.js cookies at the sub-domain level like music.optimizesmart.com then use the _setDomainName() method as shown below:

_gaq.push([‘_setDomainName’, ‘music.optimizesmart.com’]); 

If you want to set ga.js cookies at the sub-sub-domain level like asian.music.optimizesmart.com then use the _setDomainName() method as shown below:

_gaq.push([‘_setDomainName’, ‘asian.music.optimizesmart.com’]); 

#2 _setCookiePath()

This method is used to set the path to which the ga.js cookies will be set.

By default, the ga.js cookies are set on the top-level domain with the root level (/) path. If you want to modify the cookie path from the default ‘/’ to say ‘/lib’, then use the _setCookiePath() method as shown below:

_gaq.push([‘_setCookiePath’, ‘/lib/’]);

Note: Google does not recommend changing the cookie path.

#3 _setVisitorCookieTimeout()

This method is used to change the expiration time of the _utma cookie. The expiration time is specified in milliseconds.

1 millisecond = 0.001 seconds

By default, _utma cookie expires after two years. But you can set it to expire after one week or any time you want to. For example:

_gaq.push([‘_setVisitorCookieTimeout’, 604800000]);

Here _setVisitorCookieTimeout() method sets _utma cookie to expire after 604800000 milliseconds or 1 week.

Note: Use a search query like ‘1 week in milliseconds’ on Google to convert any time into milliseconds.

If you want the _utma cookie to expire as soon as the browser window is closed, set the expiration timeout to 0. For example:

_gaq.push([‘_setVisitorCookieTimeout’, 0]);

#4 _setSessionCookieTimeout()

This method is used to change the expiration time of the _utmb cookie. The expiration time is specified in milliseconds.

By default, _utmb cookie expires after 30 minutes. But you can set it to expire after any time you want to. For example:

_gaq.push([‘_setSessionCookieTimeout’, 100000]);

Here, you tell Google Analytics to end a web session after 100000 milliseconds or 100 seconds.

If you want _utmb cookie to expire as soon as the browser window is closed, set the expiration timeout to 0. For example:

_gaq.push([‘_setSessionCookieTimeout’, 0]);

#5 _setCampaignCookieTimeout

This method is used to change the expiration time of the _utmz cookie. The expiration time is specified in milliseconds.

By default, _utmz cookie expires after six months. But you can set it to expire after any time you want to. For example:

_gaq.push([‘_setCampaignCookieTimeout’, 100000]);

Here, you tell Google Analytics to delete the campaign cookie (_utmz) after 100 seconds.

A 100 seconds time out means, Google Analytics will attribute conversion to a campaign for up to 100 seconds or until the campaign cookie value is overwritten with another value.

If you want the _utmz cookie to expire as soon as the browser window is closed, set the expiration timeout to 0. For example:

_ gaq.push([‘_setCampaignCookieTimeout’, 0]);

Following is an example of how _setSessionCookieTimeout() and _setCampaignCookieTimeout methods can be used in your Google Analytics Tracking Code:

ga cookies session settings2
  1. Cross Domain Tracking in Google Analytics – Complete Guide
  2. How to check cross-domain tracking in Google Analytics
  3. Google Analytics Subdomain Tracking Tutorial
  4. Cross Domain Tracking with Google Tag Manager (GTM)
  5. Cross Domain Tracking in GA4 (Google Analytics 4) Setup Guide
  6. Setting up Sales Funnel across websites in Google Analytics
  7. Google Analytics GDPR checklist. Become GDPR compliant using GA
  8. Track the Impact of Google Analytics Cookie Consent on Website Traffic.

Frequently Asked Questions About Google and Universal Analytics Cookies Tutorial?

What is a cookie?

A cookie is a text file which is used to:

– Store information about user preferences, user location, and other details
– Protect user data from unauthorized access
– Maintain certain websites’ functionality
– Serve personalize ads to users and make advertising more effective via re-marketing
– Collect Google Analytics data and other tracking data.

Where are cookies stored?

Cookies are stored on a user’s hard disk and can be enabled or disabled via web browser settings.

What types of cookies are there?

There are two types of cookies:
First-Party Cookies – These cookies are issued by the website being visited, and only the website which issued the first-party cookies can read them.
Third-Party Cookies – These cookies are issued by the website(s) other than the website being visited.

Do all cookies have an expiration date?

Cookies (both first and third-party cookies) can be set with or without an expiration date.

The cookies set without an expiration date are known as temporary cookies. Such cookies expire when you end the web session or close the browser window.

The cookies set with an expiration date are known as 
persistent cookies. Such cookies expire only on the expiration date and can remain on your computer even when you have ended the web session or closed your browser window.

When are Google Analytics cookies created?

Google Analytics Cookies are created as soon as you visit a website on which a valid Google Analytics tracking code is installed and is fired.

Since all cookies are browser-specific, if you return to a website via another web browser, Google Analytics will set a different set of cookies. If a GA cookie already exists, it is updated to collect users’ data. So if you try to create a cookie that already exists, it will be overwritten.

Register for the FREE TRAINING...

"How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."



Here’s what we’re going to cover in this training…

#1 Why digital analytics is the key to online business success.

​#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.

#3 Why Google and Facebook ads don’t work for most businesses & how to make them work.

#4 ​Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.

#5 The number 1 reason why conversion optimization is not working for your business.

#6 How to advertise on any marketing platform for FREE with an unlimited budget.

​#7 How to learn and master digital analytics and conversion optimization in record time.



   

My best selling books on Digital Analytics and Conversion Optimization

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution Modelling in Google Analytics and BeyondSECOND EDITION OUT NOW!
Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour.

Attribution Modelling in Google Ads and Facebook
This book has been written to help you implement attribution modelling in Google Ads (Google AdWords) and Facebook. It will teach you, how to leverage the knowledge of attribution modelling in order to understand the customer purchasing journey and determine the most effective marketing channels for investment.

About the Author

Himanshu Sharma

  • Founder, OptimizeSmart.com
  • Over 15 years of experience in digital analytics and marketing
  • Author of four best-selling books on digital analytics and conversion optimization
  • Nominated for Digital Analytics Association Awards for Excellence
  • Runs one of the most popular blogs in the world on digital analytics
  • Consultant to countless small and big businesses over the decade

Learn and Master Google Analytics 4 (GA4) - 126 pages ebook

X
error: Alert: Content is protected !!