August 13, 2021
Missing DOM Ready and Window Loaded events in GTM?
This will be a very quick guide, and it’s based on one of the recent posts in the GTM community on Facebook.
Simo Ahava’s eagle eyes spotted a weird thing that was implemented on a site. For some reason, an empty array was being pushed to the Data Layer like this (which is not a valid command for GTM):
If you want to push data to the Data Layer, it must be an object or a command array. And an empty array is neither of those.
So what must be done? You have to cooperate with a developer and ask him/her to remove the dataLayer.push that adds an empty array. Or disable a plugin that is doing so (if you are working with a popular website builder/ecommerce platform.
Unfortunately, there is no universal “go here, click this” answer. Websites are different and most of their codebase is different. So you should probably cooperate/consult with a person/company that is responsible for building that website.
Still missing DOM Ready and Window Loaded events?
If this tip did not help you, leave a comment below, and we’ll try to find a solution + update the guide. And if this indeed worked well, consider subscribing to my newsletter by getting one of these ebooks.