• Courses
    • Courses
    • Course bundles
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login
  • Courses
    • Courses
    • Course bundles
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login

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.

One of the members faced a situation where DOM ready (a.k.a. gtm.dom) and Window Loaded (a.k.a. gtm.load) were missing in the Data Layer although the Container Loaded event (gtm.js) worked just fine.

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.

Google Tag Manager Ebook Bundle
Julius Fedorovicius
In Google Analytics Tips
3 COMMENTS
Derek
  • Jul 13 2021
  • Reply

This tip is exactly what I was looking for but did not seem to work on my current site. I was unable to find an empty array. Just wondering if you can see the issue. Also, there is additional coding for //CDATA within the Google Analytics script. I prefer to run GA through GTM but I inherited the site with this set up. Would you recommend removing the GA script or at a minimum the //CDATA? Thank you for all your help, Derek

Will Earp
  • Jan 12 2022
  • Reply

If you import the script with a dynamic import, the CSP will prevent the preview mode from working, but the browser will not warn you in the console.

    Will Earp
    • Jan 12 2022
    • Reply

    Sorry this was for another article: https://www.analyticsmania.com/post/google-tag-manager-preview-mode-not-working/#comment-30583

Leave a comment Cancel reply

Your email address will not be published. Required fields are marked *


 

Hi, I'm Julius Fedorovicius and I'm here to help you learn Google Tag Manager and Google Analytics. Join thousands of other digital marketers and digital analysts in this exciting journey. Read more
Analytics Mania
  • Google Tag Manager Courses
  • Google Tag Manager Recipes
  • Google Tag Manager Resources
  • Google Tag Manager Community
  • Login to courses
Follow Analytics Mania
  • Subscribe to newsletter
Recent Posts
  • Conversion rate in Google Analytics 4
  • Google Tag Manager Data Layer Explained
  • Cross-domain tracking in Google Analytics 4
Analytics Mania - Google Tag Manager and Google Analytics Blog | Privacy Policy
Manage Cookie Settings