Google Analytics - Utma Cookie

About

The Utma cookie is one of the Ga cookie that fulfill the role of cookie identifier

The __utma cookie is used to distinguish

Format

The cookie is created when the javascript library executes and no existing __utma cookies exists. The cookie is updated every time data is sent to Google Analytics.

utma=67809543.1161459517.1575879169.1576068631.1576087033.11

where:

  • 67809543, the first number is the domain hash
  • 1161459517.1575879169 is the client id
  • 1576068631, the fourth number is the epoch timestamp (in second) of the previous session
  • 1576087033, the fifth number is the epoch timestamp (in second) of the current session
  • 11, the last number is the number of session. If you don't have any interaction with the website for more than one minute, a new session is created.

Storage

It's stored as a first-party cookie with a two-year expiration

How to read it programmatically ?

cookie_key = "__utma";
regexp = new RegExp("(?:(?:^|.*;\\s*)"+cookie_key+"\\s*\\=\\s*([^;]*).*$)|^.*$");
var utmaValue = parent.document.cookie.replace(regexp, "$1");
console.log('Your utma value is '+utmaValue);
utmas = utmaValue.split('.');
console.log('Initial Visit was at: '+(new Date(1000*utmas[2])));
console.log('Previous Visit was at: '+(new Date(1000*utmas[3])));
console.log('Current Visit was at:  '+(new Date(1000*utmas[4])));
console.log('Your number of visit is:  '+utmas[5]);

Powered by ComboStrap