{"id":8159,"date":"2017-09-05T11:37:53","date_gmt":"2017-09-05T11:37:53","guid":{"rendered":"https:\/\/xpon.ai\/resources\/tracking-cookie-size-in-google-analytics\/"},"modified":"2026-03-23T05:10:32","modified_gmt":"2026-03-23T05:10:32","slug":"tracking-cookie-size-in-google-analytics","status":"publish","type":"post","link":"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/","title":{"rendered":"A Guide To Track Cookie Size In Google Analytics"},"content":{"rendered":"<p>Why is it important to track cookie size? In my previous article (<a href=\"https:\/\/xpon.ai\/au\/resources\/whats-your-cookie-size-are-you-safe\/\">What&#8217;s your cookie-size &#8211; are you on the safe side?<\/a>), I demonstrated the situation when a third-party marketing script could damage your business: may prevent your returning visitors from coming back to your website. Obviously, sooner or later the situation can be discovered and fixed by IT, but this would be a <em>reactive<\/em> approach &#8211; not <em>proactive<\/em>. The best thing about Google Analytics is that we can be proactive and track almost anything!<\/p>\n<blockquote><p>The best thing about Google Analytics is that we can be proactive with and track almost anything!<\/p><\/blockquote>\n<h4><strong>Why you should track cookie size<\/strong><\/h4>\n<p>I propose that it is important to track the cookie size associated with your website. If the percentage of users with a cookie size greater than 4 kilobytes goes up, have Google Analytics send you automated alert. This way, you will be able to address the situation long before it damages your business.<\/p>\n<p>Technically, cookies are a small bit of information being transferred to your website with every request and there is no way you can access other website cookies (under normal circumstances), but <a href=\"https:\/\/xpon.ai\/au\/resources\/the-importance-of-server-side-tagging-in-a-cookieless-world\/\">cookies associated with your website are yours<\/a> and you can do whatever you want with them. In this case, all we need is their size. To get cookie size using JavaScript, execute in your browser console:<\/p>\n<pre>document.cookie.length<\/pre>\n<p><span style=\"font-family: 'Open Sans', Ubuntu, sans-serif; font-size: 1.125rem;\">This will print the size of the cookies associated with the current website. As you can see in the screenshot above, cookie size is 2597 bytes or 2.5 kilobytes. We can save this number as a Custom Metric in Google Analytics, however I don&#8217;t believe this would be useful. To make our analysis effective, I would assign current pageview (or Session) to a limited number of buckets:<\/span><\/p>\n<ul>\n<li>Tiny: &lt; 500 bytes of cookies<\/li>\n<li>500&#8230;1k: cookie size is between 500 bytes to 1 kilobyte of cookies<\/li>\n<li>1k..2k: cookie size is between one and two kilobytes<\/li>\n<li>2k..4k: cookie size is between two and four kilobytes<\/li>\n<li>4k..8k: cookie size is between four and eight kilobytes<\/li>\n<li>More than 8 kilobytes<\/li>\n<\/ul>\n<p>The last two buckets put a user into the red zone and a sudden increase of hits\/sessions in these buckets should be a trigger for a Google Analytics Custom Alert.<\/p>\n<p>Unfortunately, the method above will not include the <em>HttpOnly<\/em> cookies often used for authentication purpose. HttpOnly cookies are special in a way that JavaScript can&#8217;t access it and they are solely for the use of your webserver. Since we can&#8217;t access these cookies, we can&#8217;t track them. Well, we can using a server-side tracking but it is a completely different story.<\/p>\n<h4><strong>Sounds good, how can I do this?<\/strong><\/h4>\n<p>At Internetrix, we use Google Tag Manager. The following guide covers <span style=\"font-family: 'Open Sans', Ubuntu, sans-serif; font-size: 18px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal;\">cookie size tracking setup <\/span><span style=\"font-family: 'Open Sans', Ubuntu, sans-serif; font-size: 1.125rem;\">step by step. If you are not using Google Tag Manager yet, or use another Tag Manager solution, this can easily <\/span><span style=\"font-family: 'Open Sans', Ubuntu, sans-serif; font-size: 18px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal;\">be<\/span> <span style=\"font-family: 'Open Sans', Ubuntu, sans-serif; font-size: 1.125rem;\">replicated using other tools. It is just JavaScript.<\/span><\/p>\n<p>First, we need to create a Custom Dimension in Google Analytics Property settings. It does not matter how you name the Custom Dimension, but please note the assigned dimension index.<\/p>\n<p>Let&#8217;s switch to Google Tag Manager and create a Variable which returns for <span style=\"font-family: 'Open Sans', Ubuntu, sans-serif; font-size: 18px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal;\">the current hit which <\/span><span style=\"font-family: 'Open Sans', Ubuntu, sans-serif; font-size: 1.125rem;\">cookie size bucket it goes into. In Google Tag Manager, Click on Variables and click on New button. Name variable: <\/span><em style=\"font-family: 'Open Sans', Ubuntu, sans-serif; font-size: 1.125rem;\">Page Cookie Size Categorised<\/em><span style=\"font-family: 'Open Sans', Ubuntu, sans-serif; font-size: 1.125rem;\"> and copy\/paste the following into Custom JavaScript field<\/span><\/p>\n<pre>function(){\r\n var cookieSize = document.cookie.length;\r\n var ret = 'unknown';\r\n if(!isNaN(cookieSize)){\r\n if(cookieSize &lt; 500)\r\n ret = '&lt; 500';\r\n else if(cookieSize &lt; 1024)\r\n ret = '500 b ... 1k';\r\n else if(cookieSize &lt; 2048)\r\n ret = '1k...2k';\r\n else if(cookieSize &lt; 4096)\r\n ret = '2k...4k';\r\n else if(cookieSize &lt; 8192)\r\n ret = '4k...8k';\r\n else\r\n ret = 'more than 8k'; \r\n }\r\n\r\n return ret; \r\n}<\/pre>\n<p>Click Save. As you can see the variable assigns cookie size to one of the buckets and returns it to us. All that is left to do is to save it as Custom Dimension in our Pageview tag.<\/p>\n<p>In the screenshot above, the Variable <em>IRX &#8211; Setting &#8211; Dimension Index &#8211; Cookie Size<\/em> is a constant holding index of a Custom Dimension in your GA Property where you are sending cookie size and <em>Page Cookie Size Categorised<\/em> as a Variable we have created in the previous step.<\/p>\n<p>Now, save the tag and publish your container (do not forget to test it!). That&#8217;s pretty much it.<\/p>\n<p>Allow the data to be collected and create a Custom Report using this Cookie Size Custom Dimension and Sessions, Conversion Rate as metrics.<\/p>\n<p>Well done!<\/p>\n<p>Need help with your analytics to become more data-driven in your approach? Talk to us about your ideas. Internetrix combines digital consulting with winning website design, smart website development, and strong digital analytics and digital marketing skills to drive revenue or cut costs for our clients. We deliver web-based consulting, development and performance projects to customers across the Asia Pacific ranging from small business sole traders to ASX listed businesses and all levels of the Australian government.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Why is it important to track cookie size? In my previous article (What&#8217;s your cookie-size &#8211; are you on the safe side?), I demonstrated the situation when a third-party marketing script could damage your business: may prevent your returning visitors from coming back to your website. Obviously, sooner or later the situation can be discovered [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_focuskw":"Track Cookie Size","_yoast_wpseo_title":"Track Cookie Size %%sep%% %%sitename%%","_yoast_wpseo_metadesc":"Even though the cookie landscape is changing, I propose that it is important to track the cookie size associated with your website.","_yoast_wpseo_meta-robots-noindex":"","_yoast_wpseo_meta-robots-nofollow":"","_yoast_wpseo_canonical":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"categories":[389],"tags":[],"class_list":["post-8159","post","type-post","status-publish","format-standard","hentry","category-blog-au"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.2 (Yoast SEO v21.4) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>A Guide To Track Cookie Size In Google Analytics | XPON Technologies | XPON Australia<\/title>\n<meta name=\"description\" content=\"Why is it important to track cookie size? In my previous article (What&#039;s your cookie-size - are you on the safe side?), I demonstrated the situation when | XPON Australia\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/xpon.ai\/au\/wp-json\/wp\/v2\/posts\/8159\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"A Guide To Track Cookie Size In Google Analytics | XPON Australia\" \/>\n<meta property=\"og:description\" content=\"Why is it important to track cookie size? In my previous article (What&#039;s your cookie-size - are you on the safe side?), I demonstrated the situation when | XPON Australia\" \/>\n<meta property=\"og:url\" content=\"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/\" \/>\n<meta property=\"og:site_name\" content=\"XPON Technologies\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/xpongroup\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-05T11:37:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-03-23T05:10:32+00:00\" \/>\n<meta name=\"author\" content=\"XPON Technologies Group\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@xpontech\" \/>\n<meta name=\"twitter:site\" content=\"@xpontech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"XPON Technologies Group\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/\"},\"author\":{\"name\":\"XPON Technologies Group\",\"@id\":\"https:\/\/xpon.ai\/au\/#\/schema\/person\/aa8c496cc9248f72a86ab557e0bed6e1\"},\"headline\":\"A Guide To Track Cookie Size In Google Analytics\",\"datePublished\":\"2017-09-05T11:37:53+00:00\",\"dateModified\":\"2026-03-23T05:10:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/\"},\"wordCount\":787,\"publisher\":{\"@id\":\"https:\/\/xpon.ai\/au\/#organization\"},\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-AU\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/\",\"url\":\"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/\",\"name\":\"A Guide To Track Cookie Size In Google Analytics | XPON Technologies\",\"isPartOf\":{\"@id\":\"https:\/\/xpon.ai\/au\/#website\"},\"datePublished\":\"2017-09-05T11:37:53+00:00\",\"dateModified\":\"2026-03-23T05:10:32+00:00\",\"description\":\"Why is it important to track cookie size? In my previous article (What's your cookie-size - are you on the safe side?), I demonstrated the situation when\",\"breadcrumb\":{\"@id\":\"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/#breadcrumb\"},\"inLanguage\":\"en-AU\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/xpon.ai\/au\/?page_id=2678\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"A Guide To Track Cookie Size In Google Analytics\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/xpon.ai\/au\/#website\",\"url\":\"https:\/\/xpon.ai\/au\/\",\"name\":\"XPON Technologies\",\"description\":\"Technology &amp; cloud solutions to modernise marketing operations\",\"publisher\":{\"@id\":\"https:\/\/xpon.ai\/au\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/xpon.ai\/au\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-AU\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/xpon.ai\/au\/#organization\",\"name\":\"XPON Technologies\",\"alternateName\":\"XPON\",\"url\":\"https:\/\/xpon.ai\/au\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-AU\",\"@id\":\"https:\/\/xpon.ai\/au\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/xpon.ai\/wp-content\/uploads\/2026\/03\/XPON_logomark_RGB_medium.png\",\"contentUrl\":\"https:\/\/xpon.ai\/wp-content\/uploads\/2026\/03\/XPON_logomark_RGB_medium.png\",\"width\":212,\"height\":212,\"caption\":\"XPON Technologies\"},\"image\":{\"@id\":\"https:\/\/xpon.ai\/au\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/xpongroup\/\",\"https:\/\/twitter.com\/xpontech\",\"https:\/\/www.youtube.com\/@xpon\/videos\",\"https:\/\/au.linkedin.com\/company\/xpon-technologies\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/xpon.ai\/au\/#\/schema\/person\/aa8c496cc9248f72a86ab557e0bed6e1\",\"name\":\"XPON Technologies Group\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-AU\",\"@id\":\"https:\/\/xpon.ai\/au\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/038bb62ee334e679305b3c014dd2e35151d0bb7f0c8350fe0f981035fdc10195?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/038bb62ee334e679305b3c014dd2e35151d0bb7f0c8350fe0f981035fdc10195?s=96&d=mm&r=g\",\"caption\":\"XPON Technologies Group\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"A Guide To Track Cookie Size In Google Analytics | XPON Technologies | XPON Australia","description":"Why is it important to track cookie size? In my previous article (What's your cookie-size - are you on the safe side?), I demonstrated the situation when | XPON Australia","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/xpon.ai\/au\/wp-json\/wp\/v2\/posts\/8159","og_locale":"en_US","og_type":"article","og_title":"A Guide To Track Cookie Size In Google Analytics | XPON Australia","og_description":"Why is it important to track cookie size? In my previous article (What's your cookie-size - are you on the safe side?), I demonstrated the situation when | XPON Australia","og_url":"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/","og_site_name":"XPON Technologies","article_publisher":"https:\/\/www.facebook.com\/xpongroup\/","article_published_time":"2017-09-05T11:37:53+00:00","article_modified_time":"2026-03-23T05:10:32+00:00","author":"XPON Technologies Group","twitter_card":"summary_large_image","twitter_creator":"@xpontech","twitter_site":"@xpontech","twitter_misc":{"Written by":"XPON Technologies Group","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/#article","isPartOf":{"@id":"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/"},"author":{"name":"XPON Technologies Group","@id":"https:\/\/xpon.ai\/au\/#\/schema\/person\/aa8c496cc9248f72a86ab557e0bed6e1"},"headline":"A Guide To Track Cookie Size In Google Analytics","datePublished":"2017-09-05T11:37:53+00:00","dateModified":"2026-03-23T05:10:32+00:00","mainEntityOfPage":{"@id":"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/"},"wordCount":787,"publisher":{"@id":"https:\/\/xpon.ai\/au\/#organization"},"articleSection":["Blog"],"inLanguage":"en-AU"},{"@type":"WebPage","@id":"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/","url":"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/","name":"A Guide To Track Cookie Size In Google Analytics | XPON Technologies","isPartOf":{"@id":"https:\/\/xpon.ai\/au\/#website"},"datePublished":"2017-09-05T11:37:53+00:00","dateModified":"2026-03-23T05:10:32+00:00","description":"Why is it important to track cookie size? In my previous article (What's your cookie-size - are you on the safe side?), I demonstrated the situation when","breadcrumb":{"@id":"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/#breadcrumb"},"inLanguage":"en-AU","potentialAction":[{"@type":"ReadAction","target":["https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/xpon.ai\/au\/resources\/tracking-cookie-size-in-google-analytics\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/xpon.ai\/au\/?page_id=2678"},{"@type":"ListItem","position":2,"name":"A Guide To Track Cookie Size In Google Analytics"}]},{"@type":"WebSite","@id":"https:\/\/xpon.ai\/au\/#website","url":"https:\/\/xpon.ai\/au\/","name":"XPON Technologies","description":"Technology &amp; cloud solutions to modernise marketing operations","publisher":{"@id":"https:\/\/xpon.ai\/au\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/xpon.ai\/au\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-AU"},{"@type":"Organization","@id":"https:\/\/xpon.ai\/au\/#organization","name":"XPON Technologies","alternateName":"XPON","url":"https:\/\/xpon.ai\/au\/","logo":{"@type":"ImageObject","inLanguage":"en-AU","@id":"https:\/\/xpon.ai\/au\/#\/schema\/logo\/image\/","url":"https:\/\/xpon.ai\/wp-content\/uploads\/2026\/03\/XPON_logomark_RGB_medium.png","contentUrl":"https:\/\/xpon.ai\/wp-content\/uploads\/2026\/03\/XPON_logomark_RGB_medium.png","width":212,"height":212,"caption":"XPON Technologies"},"image":{"@id":"https:\/\/xpon.ai\/au\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/xpongroup\/","https:\/\/twitter.com\/xpontech","https:\/\/www.youtube.com\/@xpon\/videos","https:\/\/au.linkedin.com\/company\/xpon-technologies"]},{"@type":"Person","@id":"https:\/\/xpon.ai\/au\/#\/schema\/person\/aa8c496cc9248f72a86ab557e0bed6e1","name":"XPON Technologies Group","image":{"@type":"ImageObject","inLanguage":"en-AU","@id":"https:\/\/xpon.ai\/au\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/038bb62ee334e679305b3c014dd2e35151d0bb7f0c8350fe0f981035fdc10195?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/038bb62ee334e679305b3c014dd2e35151d0bb7f0c8350fe0f981035fdc10195?s=96&d=mm&r=g","caption":"XPON Technologies Group"}}]}},"_links":{"self":[{"href":"https:\/\/xpon.ai\/au\/wp-json\/wp\/v2\/posts\/8159","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xpon.ai\/au\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xpon.ai\/au\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xpon.ai\/au\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/xpon.ai\/au\/wp-json\/wp\/v2\/comments?post=8159"}],"version-history":[{"count":0,"href":"https:\/\/xpon.ai\/au\/wp-json\/wp\/v2\/posts\/8159\/revisions"}],"wp:attachment":[{"href":"https:\/\/xpon.ai\/au\/wp-json\/wp\/v2\/media?parent=8159"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xpon.ai\/au\/wp-json\/wp\/v2\/categories?post=8159"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xpon.ai\/au\/wp-json\/wp\/v2\/tags?post=8159"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}