About cookies on this site

We use cookies to collect and analyse information on site performance and usage, to provide social media features and to enhance and customise content and advertisements. Learn more

Cookie settings

About cookies on this site

Cookies used on the site are categorized and below you can read about each category and allow or deny some or all of them. Learn more

Necessary

Some cookies are required to provide core functionality. The website won't function properly without these cookies and they are enabled by default and cannot be disabled.

Preferences

Preference cookies enables the web site to remember information to customize how the web site looks or behaves for each user. This may include storing selected currency, region, language or color theme.

Analytical cookies

Analytical cookies help us improve our website by collecting and reporting information on its usage.

Marketing cookies

Marketing cookies are used to track visitors across websites to allow publishers to display relevant and engaging advertisements. By enabling marketing cookies, you grant permission for personalized advertising across various platforms.

  • Courses
    • Paid courses
    • Course bundles
    • Free courses
  • Blog
  • Resources
    • Youtube channel
    • E-books and Guides
    • GTM Recipes
    • View All Resources
    • GTM Community
    • GA4 community
  • Services
  • About
    • About
    • Contact
  • Login
  • Courses
    • Paid courses
    • Course bundles
    • Free courses
  • 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
  • Google Tag Manager event tracking – The Guide
  • DebugView in Google Analytics 4 not working? Here are 18 solutions.
  • Google Analytics 4 User ID for cross-device tracking: how to configure it
Analytics Mania - Google Tag Manager and Google Analytics Blog | Privacy Policy
Manage Cookie Settings