About
The Utmb cookie is one of the Ga cookie that fulfill the role of session cookie
It's used to determine new sessions/visits.
Articles Related
Management
- The cookie is created when the javascript library executes and it does not exists.
- The cookie is updated every time data is sent to Google Analytics.
- The cookie is deleted after 30 mins of inactivity (via the cookie expiration date)
Structure
The utmb cookie contains the session identifier visitId (Doc. This is only unique to the user. For a completely unique ID, you should use a combination of fullVisitorId and visitId.
Example:
67809543.362.8.1578905981775
where:
- 67809543, the first number is the domain hash
- 362 is the session id (visitId)
- 8, the number of session ?
- 1578905981775, the fourth number is the epoch timestamp (in second)
How to read it programmatically ?
cookie_key = "__utmb";
regexp = new RegExp("(?:(?:^|.*;\\s*)"+cookie_key+"\\s*\\=\\s*([^;]*).*$)|^.*$");
var utmbValue = parent.document.cookie.replace(regexp, "$1");
console.log('Your utmb value is '+utmbValue);
utmbs = utmbValue.split('.');
console.log('Domain Hash is: '+utmbs[0]);
console.log('The visitId ? is: '+utmbs[1]);
console.log('The number of visit ? is: '+utmbs[2]);
console.log('The last interaction was at: '+(new Date(Number(utmbs[3]))));