In my previous article (What's your cookie-size - 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 and fixed by IT, but this would be a reactive approach - not proactive. The best thing about Google Analytics is that we can be proactive and track almost anything!
The best thing about Google Analytics is that we can be proactive with and track almost anything!
I propose to track your visitors' 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.
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't believe this would be useful. To make our analysis effective, I would assign current pageview (or Session) to a limited number of buckets:
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.
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.
var cookieSize = document.cookie.length;
var ret = 'unknown';
if(cookieSize < 500)
ret = '< 500';
else if(cookieSize < 1024)
ret = '500 b ... 1k';
else if(cookieSize < 2048)
ret = '1k...2k';
else if(cookieSize < 4096)
ret = '2k...4k';
else if(cookieSize < 8192)
ret = '4k...8k';
ret = 'more than 8k';
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.
In the screenshot above, the Variable IRX - Setting - Dimension Index - Cookie Size is a constant holding index of a Custom Dimension in your GA Property where you are sending cookie size and Page Cookie Size Categorised as a Variable we have created in the previous step.
Now, save the tag and publish your container (do not forget to test it!). That's pretty much it.
Allow the data to be collected and create a Custom Report using this Cookie Size Custom Dimension and Sessions, Conversion Rate as metrics.
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 Australian government.