Google Tag Manager Message Length Limit for Google Analytics

By 15th May 2015December 18th, 2017Digital Marketing, Web Analytics & Reporting
Google Analytics & Tag Manager

At LogicSpot, we’re always trying to set up Analytics with Enhanced Ecommerce support using Google Tag Manager (GTM) for our Magento clients. This is because we feel that, further along the line, it is much easier to maintain changes to existing tags as well as any new third party tags. In most cases we don’t even need to change the code.

However, sometimes we encounter problems caused by poor GTM documentation. A while ago we noticed that one of our Magento Client’s Product Lists was not tracking properly on Enhanced Ecommerce Analytics view, and the problem seemed to be inconsistent – some of the categories were not tracked while some worked perfectly.

We ‘re using a custom module to implement GTM, so once we had excluded our code as a possible cause of the problem we started debugging Analytics and its responses.

Google Analytics debugger

Using the Google Analytics Debugger plugin for Chrome we found out that for categories that aren’t working, we get an error. The message doesn’t tell us a lot, however one can assume that it has something to do with the length of message sent to Google Analytics… This could explain why some of the categories were being tracked, and some not.

We tested our assumption – by reducing the number of products within the problematic categories – and noticed that this was, indeed, a problem.

We searched through Google and Tag Manager Developer Documentation, however nothing indicated any length limit. So we posted a question on the Tag Manager product forum and, thanks to the help of a Google employee, it turns out there’s a 8k limit on hit sizes – and our biggest categories were sending over 11k of data!

Before we encountered this problem, we were using the standard Product impression tracking configuration as suggested in Google Developers . We then found out that it is actually possible to track long categories, we just needed to make a few adjustments. Instead of pushing the whole product impression list into dataLayer in JSON data, we could push the product impressions in batches. So if you also want to do it, all you need to do is to adjust your code to send multiple instances of dataLayer.push with a custom event (we’ve named it productImpressions). Once you’ve done that, you can then configure Tag Manager in a similar way.

Preview mode Tag Manager

After you’ve set this up, you can then test to see if your changes are working correctly (or not!) by enabling Debug mode in Tag Manager. Visiting large categories should result in multiple calls of productImpressions tag. As it runs out 24 hours later in Analytics our fix worked, and all categories for our client were tracked properly from this moment.

If you’re interested to learn more about our custom Google Tag Manager module for Magento, don’t hesitate to contact us!