Cookies Sizes
Overview
This custom tag will find all of the cookies set on the page and report the name-value pair and the size (in bytes) of the cookie.
Under the Variable Inventory report, select ObservePoint Data and under Cookies Sizes you can find the relevant information.
- cookie#-NameValue: Collects the name-value pair of the cookie
- cookie#-size: Collects the cookies size (in bytes)
function opReqGetAsync(paramObject, acct, callback) { var baseURL = window.location.protocol+"//"+window.location.hostname+"/observepointcustomtag?acct=" + acct; var opReq = new XMLHttpRequest(); opReq.onreadystatechange = function() { if (opReq.readyState === 4 && opReq.status === 200) { callback(opReq.responseText); } } opReq.open("POST", baseURL, true); opReq.send(JSON.stringify(paramObject)); } var obj = {}; let cookieSizes = document.cookie.split('; ').map(cookie => [cookie, encodeURI(cookie).split(/%..|./).length - 1]) cookieSizes.forEach((cookie, index)=> { let newIndex = index + 1; obj['cookie' + newIndex + '-NameValue'] = cookie[0]; obj['cookie' + newIndex + '-Size'] = cookie[1]; }); opReqGetAsync(obj, 'Cookie Size');