{"id":134408,"date":"2025-03-15T04:00:20","date_gmt":"2025-03-15T04:00:20","guid":{"rendered":"https:\/\/peraltafinancing.com\/analytics\/gtmtips-check-if-dom-ready-or-window-loaded-have-fired\/"},"modified":"2025-03-15T04:00:20","modified_gmt":"2025-03-15T04:00:20","slug":"gtmtips-check-if-dom-ready-or-window-loaded-have-fired","status":"publish","type":"post","link":"https:\/\/fivemor.com\/?p=134408","title":{"rendered":"#GTMTips: Check If DOM Ready Or Window Loaded Have Fired"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<p>Every now and then I run into a problem which needs some creativity to find a fix. When choosing a course of action, I tend to land first on an extremely complicated solution. However, if I\u2019m patient enough, I manage to whittle it down to something far more manageable and efficient.<\/p>\n<p>In this <a href=\"https:\/\/www.simoahava.com\/categories\/gtm-tips\/\">#GTMTips<\/a> post, I\u2019ll show you one of these extremely simple solutions to a problem which you might normally overcomplicate. The solution is a very well hidden feature of <a href=\"https:\/\/tagmanager.google.com\/\">Google Tag Manager<\/a>, buried deep in the bowels of the <code>google_tag_manager<\/code> interface.<\/p>\n<p>                <span class=\"simmer\"><br \/>\n  <span class=\"close\">X<\/span><\/p>\n<p>\n    <span class=\"fa fa-md fa-bell\"\/><br \/>\n    <strong>The Simmer Newsletter<\/strong>\n  <\/p>\n<p>\n    Subscribe to the <a href=\"https:\/\/www.simoahava.com\/newsletter\/\">Simmer newsletter<\/a> to get the latest news and content from Simo Ahava into your email inbox!\n  <\/p>\n<p>  <\/span><\/p>\n<h2 id=\"tip-42-check-if-dom-ready-or-window-loaded-have-triggered\">Tip 42: Check if DOM Ready or Window Loaded have triggered<\/h2>\n<div style=\"aspect-ratio: 960 \/ 540;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2016\/02\/gtmtips-check-dom-ready-window-loaded.jpg\" title=\"Check if Window Loaded or DOM Ready have triggered\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"540\" width=\"960\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2016\/02\/gtmtips-check-dom-ready-window-loaded.jpg#ZgotmplZ\" alt=\"Check if Window Loaded or DOM Ready have triggered\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>This tip is very, very simple. Basically, there are two flags in the <code>google_tag_manager<\/code> interface, and they are activated first when the \u201cDOM Ready\u201d event takes place, and then when the \u201cWindow Loaded\u201d event takes place.<\/p>\n<p>If you didn\u2019t have access to these flags, your remaining options would be something horrible like going through the <code>dataLayer<\/code> Array, looking for the <strong>gtm.dom<\/strong> and <strong>gtm.load<\/strong>, or creating your own listeners for the DOM and window load events. Both have timing issues in Google Tag Manager, and both add extra complexity to a situation which could already be solved using something that is native to Google Tag Manager.<\/p>\n<p>Anyway, you can use these interface flags to make sure your Triggers don\u2019t fire before either one of the page load Triggers have activated. A typical use case would be that you have a slowly loading site, and you don\u2019t want a Trigger to go off before the DOM has completely loaded or all the linked resources (e.g. jQuery) have been downloaded.<\/p>\n<p>This is how it works:<\/p>\n<div class=\"highlight\">\n<pre style=\"background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4\"><code class=\"language-javascript\" data-lang=\"javascript\"><span style=\"color:#0aa\">window<\/span>[<span style=\"color:#a50\">'google_tag_manager'<\/span>].dataLayer.gtmDom; <span style=\"color:#aaa;font-style:italic\">\/\/ true when DOM Ready has fired\n<\/span><span style=\"color:#aaa;font-style:italic\"\/><span style=\"color:#0aa\">window<\/span>[<span style=\"color:#a50\">'google_tag_manager'<\/span>].dataLayer.gtmLoad; <span style=\"color:#aaa;font-style:italic\">\/\/ true when Window Loaded has fired\n<\/span><\/code><\/pre>\n<\/div>\n<p>These are the global flags. To get the data into GTM, create two <strong>JavaScript Variables<\/strong>:<\/p>\n<div style=\"aspect-ratio: 1662 \/ 572;\" class=\"figure nocaption\">\n<p>    <a href=\"https:\/\/www.simoahava.com\/images\/2016\/02\/js-variables.jpg\" title=\"JavaScript variables\"><\/p>\n<p>    <img decoding=\"async\" class=\"fig-img\" height=\"572\" width=\"1662\" loading=\"lazy\" src=\"https:\/\/www.simoahava.com\/images\/2016\/02\/js-variables.jpg#ZgotmplZ\" alt=\"JavaScript variables\"\/><\/p>\n<p>    <\/a><\/p>\n<\/div>\n<p>Now you can check if these Variables return <strong>true<\/strong>, and use that in the Triggers to establish some order into the chaos of the page load.<\/p>\n<\/p><\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>Every now and then I run into a problem which needs some creativity to find a fix. When choosing a course of action, I tend to land first on an extremely complicated solution. However, if I\u2019m patient enough, I manage to whittle it down to something far more manageable and efficient. In this #GTMTips post, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":134409,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12033],"tags":[855,43511,23051,14492,6870,11556,2830],"dealstore":[],"offerexpiration":[],"class_list":["post-134408","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-analytics","tag-check","tag-dom","tag-fired","tag-gtmtips","tag-loaded","tag-ready","tag-window"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>#GTMTips: Check If DOM Ready Or Window Loaded Have Fired - Som2ny Network<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/fivemor.com\/?p=134408\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"#GTMTips: Check If DOM Ready Or Window Loaded Have Fired - Som2ny Network\" \/>\n<meta property=\"og:description\" content=\"Every now and then I run into a problem which needs some creativity to find a fix. When choosing a course of action, I tend to land first on an extremely complicated solution. However, if I\u2019m patient enough, I manage to whittle it down to something far more manageable and efficient. In this #GTMTips post, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/fivemor.com\/?p=134408\" \/>\n<meta property=\"og:site_name\" content=\"Som2ny Network\" \/>\n<meta property=\"article:published_time\" content=\"2025-03-15T04:00:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/gtmtips-check-dom-ready-window-loaded.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"960\" \/>\n\t<meta property=\"og:image:height\" content=\"540\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/fivemor.com\/?p=134408#article\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/?p=134408\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\"},\"headline\":\"#GTMTips: Check If DOM Ready Or Window Loaded Have Fired\",\"datePublished\":\"2025-03-15T04:00:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=134408\"},\"wordCount\":356,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=134408#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/gtmtips-check-dom-ready-window-loaded.jpg\",\"keywords\":[\"Check\",\"DOM\",\"Fired\",\"GTMTips\",\"Loaded\",\"Ready\",\"Window\"],\"articleSection\":[\"Analytics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/fivemor.com\/?p=134408#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/fivemor.com\/?p=134408\",\"url\":\"https:\/\/fivemor.com\/?p=134408\",\"name\":\"#GTMTips: Check If DOM Ready Or Window Loaded Have Fired - Som2ny Network\",\"isPartOf\":{\"@id\":\"https:\/\/fivemor.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/fivemor.com\/?p=134408#primaryimage\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/?p=134408#primaryimage\"},\"thumbnailUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/gtmtips-check-dom-ready-window-loaded.jpg\",\"datePublished\":\"2025-03-15T04:00:20+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/fivemor.com\/?p=134408#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/fivemor.com\/?p=134408\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/?p=134408#primaryimage\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/gtmtips-check-dom-ready-window-loaded.jpg\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/gtmtips-check-dom-ready-window-loaded.jpg\",\"width\":960,\"height\":540},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/fivemor.com\/?p=134408#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/fivemor.com\/?bp_activities=1\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"#GTMTips: Check If DOM Ready Or Window Loaded Have Fired\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/fivemor.com\/#website\",\"url\":\"https:\/\/fivemor.com\/\",\"name\":\"Som2ny Network\",\"description\":\"Daily Deals\",\"publisher\":{\"@id\":\"https:\/\/fivemor.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/fivemor.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/fivemor.com\/#organization\",\"name\":\"Som2ny Network\",\"url\":\"https:\/\/fivemor.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"contentUrl\":\"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png\",\"width\":300,\"height\":86,\"caption\":\"Som2ny Network\"},\"image\":{\"@id\":\"https:\/\/fivemor.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/fivemor.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/fivemor.com\"],\"url\":\"https:\/\/fivemor.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"#GTMTips: Check If DOM Ready Or Window Loaded Have Fired - Som2ny Network","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/fivemor.com\/?p=134408","og_locale":"en_US","og_type":"article","og_title":"#GTMTips: Check If DOM Ready Or Window Loaded Have Fired - Som2ny Network","og_description":"Every now and then I run into a problem which needs some creativity to find a fix. When choosing a course of action, I tend to land first on an extremely complicated solution. However, if I\u2019m patient enough, I manage to whittle it down to something far more manageable and efficient. In this #GTMTips post, [&hellip;]","og_url":"https:\/\/fivemor.com\/?p=134408","og_site_name":"Som2ny Network","article_published_time":"2025-03-15T04:00:20+00:00","og_image":[{"width":960,"height":540,"url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/gtmtips-check-dom-ready-window-loaded.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/fivemor.com\/?p=134408#article","isPartOf":{"@id":"https:\/\/fivemor.com\/?p=134408"},"author":{"name":"admin","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371"},"headline":"#GTMTips: Check If DOM Ready Or Window Loaded Have Fired","datePublished":"2025-03-15T04:00:20+00:00","mainEntityOfPage":{"@id":"https:\/\/fivemor.com\/?p=134408"},"wordCount":356,"commentCount":0,"publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"image":{"@id":"https:\/\/fivemor.com\/?p=134408#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/gtmtips-check-dom-ready-window-loaded.jpg","keywords":["Check","DOM","Fired","GTMTips","Loaded","Ready","Window"],"articleSection":["Analytics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/fivemor.com\/?p=134408#respond"]}]},{"@type":"WebPage","@id":"https:\/\/fivemor.com\/?p=134408","url":"https:\/\/fivemor.com\/?p=134408","name":"#GTMTips: Check If DOM Ready Or Window Loaded Have Fired - Som2ny Network","isPartOf":{"@id":"https:\/\/fivemor.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/fivemor.com\/?p=134408#primaryimage"},"image":{"@id":"https:\/\/fivemor.com\/?p=134408#primaryimage"},"thumbnailUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/gtmtips-check-dom-ready-window-loaded.jpg","datePublished":"2025-03-15T04:00:20+00:00","breadcrumb":{"@id":"https:\/\/fivemor.com\/?p=134408#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/fivemor.com\/?p=134408"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/?p=134408#primaryimage","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/gtmtips-check-dom-ready-window-loaded.jpg","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2025\/03\/gtmtips-check-dom-ready-window-loaded.jpg","width":960,"height":540},{"@type":"BreadcrumbList","@id":"https:\/\/fivemor.com\/?p=134408#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/fivemor.com\/?bp_activities=1"},{"@type":"ListItem","position":2,"name":"#GTMTips: Check If DOM Ready Or Window Loaded Have Fired"}]},{"@type":"WebSite","@id":"https:\/\/fivemor.com\/#website","url":"https:\/\/fivemor.com\/","name":"Som2ny Network","description":"Daily Deals","publisher":{"@id":"https:\/\/fivemor.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/fivemor.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/fivemor.com\/#organization","name":"Som2ny Network","url":"https:\/\/fivemor.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/","url":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","contentUrl":"https:\/\/fivemor.com\/wp-content\/uploads\/2026\/07\/4a0953c4-logo-300x86-1.png","width":300,"height":86,"caption":"Som2ny Network"},"image":{"@id":"https:\/\/fivemor.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/fivemor.com\/#\/schema\/person\/b85e3c3dc0e1daea076524dc8810c371","name":"admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/fivemor.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/729ae85bf62b9917e93538db2f2688ca?s=96&r=g&default=https%3A%2F%2Ffivemor.com%2Fwp-content%2Fplugins%2Fbuddypress-first-letter-avatar%2Fimages%2Fdefault%2F96%2Flatin_a.png","caption":"admin"},"sameAs":["https:\/\/fivemor.com"],"url":"https:\/\/fivemor.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/134408","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=134408"}],"version-history":[{"count":0,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/posts\/134408\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=\/wp\/v2\/media\/134409"}],"wp:attachment":[{"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=134408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=134408"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=134408"},{"taxonomy":"dealstore","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdealstore&post=134408"},{"taxonomy":"offerexpiration","embeddable":true,"href":"https:\/\/fivemor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fofferexpiration&post=134408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}