The secret GTM release

What happened to GTM on 20th May 2024?

Autor: Jan Brzobohatý

Published: Jun 24th 2024 | 5 min read

Do you use Google Tag Manager? Have you implemented some JavaScript code there? If yes, this article should be of great interest to you. If you have a lot of JavaScript logic in your GTM, you have probably already noticed issues. This article will try to give a more detailed explanation of just exactly what on earth went wrong on 20th May 2024 at 21:00.

The story already begins around 7th May, when Google began to release a new GTM version for 5 per cent of traffic. If you were lucky enough to not have any JS code in your GTM that could be impacted by the release, it likely did not affect you in any way. If not, your entire GTM collapsed, or, in the worst-case scenario, the release led to your entire website getting stuck as the JS code inside GTM got stuck in an endless loop.

This issue was incredibly hard to analyse and debug because at that point, the issue only occurred in 5 per cent of cases. Releasing an update to 5 per cent of traffic before a full release is a common practice for Google, which looks for potential breaking issues before releasing the update for all traffic. However, this time, the mechanism failed, simply because Google did not announce any release, and has not admitted that a release has taken place even after the fact. The last release in the official Google release notes is dated October 2023.

The full release for 100 per cent of traffic came on 25th May at 21:00 CEST. This was the moment when the majority of people finally began noticing the issue; until that time, the issue only occurred in 5 per cent of cases, which, in web analytics, is typically too insignificant to notice. Most of our clients have set up an alerting system via the Waaila tool, which allowed us to notice the issue even during the partial release, giving us a head-start for mitigating the impending damage that the full release would cause. Even in spite of that, we were not completely ready, simply because we did not know when the full release would happen, nor that it would happen. In the end, it was left up to us to figure out what the issue was.

Now let’s dive into the particular issues.

Issue # 1: “this”

Using this as a reference to the context of the current object is now broken. If your GTM variables return an object that works with a this reference, it most likely will not work. This is better illustrated in the following example. Let me first show how the JS code is supposed to work (and currently works in the browser console):

This is correct. Now I will try to replicate this in GTM.

First, I create a variable:

Then use it in a tag:

And the result is:

The reference to this is completely broken, as the context has been lost somewhere in the GTM variable implementation. Now let me show you a fix:

The result:

My poor programmer’s heart weeps at the sight, but at least it works.

Issue # 2: window scope

The global context, “window”, is getting lost. It looks like GTM began to make copies of objects instead of keeping references to an instance of an object. This is better illustrated below:

First, let’s see the expected behaviour in the console:

The final object correctly contains both parameters, because I have been working with the same instance of the object the whole time. Now let’s create a variable in GTM and see what it does:

Let’s try to use the variable in a tag and augment it.

And the result:

That looks okay, right? But there is an issue: the global window.check variable is a completely different instance than the one we are using in the tag itself, which is just a copy.


We cannot say with certainty that we have discovered all the issues that were introduced in this release. The issues encountered are dependent on the types of JS constructs used and it is entirely possible that there are more issues. I will be more than happy if anyone lets me know about other issues they have encountered.

It is clear to me that this article will not help anyone at this point. But I think it is quite sad that the issue has been largely ignored on the Internet and I would find it upsetting if it were allowed to fizzle out. From communications with many others in the field I know that we were by far not the only ones impacted by this. Doing a release without letting anyone know or at least acknowledging it after the fact is, in my opinion, a grave IT sin.

And the message for Google? Dear Google, if you can hear me up there 🙏, please let us know next time you are planning to publish a new version and tell us what you are changing. I promise to visit Google Cloud ⛪ at least once a week if you do.