What do they mean? In this blog post, I’ll quickly explain what Window Loaded event is and why should you care about it.

I’ll do that in the shape of FAQ (frequently asked questions).

What is Window Loaded trigger in GTM?

Window Loaded event appears in the preview mode (and in Data Layer) when the page has fully loaded, including any embedded resources (like images and scripts). In other words, it fires when not only the website content is ready but also when things like 3rd party scripts are loaded as well.

You can find this trigger by going to Triggers (in GTM interface) > New > Trigger Configuration > Window Loaded. If you want to use that one any page, leave all other settings as they are and save the trigger.

If you want to use this trigger only on certain pages, you can choose Some Window Loaded Events and then enter the condition, e.g. Page Path contains /product/ (this is obviously just an example, you’ll need to come up with a condition that fits your needs).

When should I use Window Loaded trigger?

There are many cases, for example, when you want to track a chat widget on a site and that widget’s script is loaded quite late. First, you need to make sure that the widget has loaded and only then start tracking it. Window Loaded might be a good option for that: you can fire a Custom HTML tag (the listener for that chat widget) only when Window Loaded event has fired (meaning that 3rd party scripts are also loaded).

In other cases, I’d use this trigger when I need to fire a tag that does not require 100% precision and does not need to start measuring as soon as the visitor lands on a page. Retargeting scripts (which will eventually die due to privacy enhancements in the market) are good examples. I don’t need to fire that script as soon as the page starts loading (a.k.a. Pageview trigger). It’s totally fine to fire the script later, on Window Loaded (or even MUCH later — just to be sure that a visitor had at least a theoretical chance to view my site’s content).

Or, most importantly, if you want to reduce the implications on page loading speed.

Will I lose data if I delay a tag to fire on Window Loaded?

Yes (but to some extent). The more you delay the tag in GTM, the higher the chances of missing data are. Why? Because if your page loads super slowly, some visitors will not wait for the entire page to load and will leave. In that case, the tag that fires on Window Loaded will not have a chance to fire.

That is why I said in the first half of this blog post that usually Window Loaded is used to fire tags that do not require 100% precision.

For example, some retargeting script can easily be delayed to Window Loaded if I plan to retarget visitors who have had a least a short glimpse of my site. If they leave the site before it even manages to load, what’s the point of retargeting them? Although, in reality, I’d delay that tag even more.

GA Pageview tag, on the other hand, requires precision because I want to know how many people/devices visited my site and I expect that number to be as precise as possible. That’s why I’d fire the GA pageview tag on a Page View event.

So what is the potential data loss if we compare a tag that fires on Pageview vs Window Loaded? Here’s an example. I’ve set a GA tag to fire on 3 different triggers:

Page view

DOM Ready

Window Loaded

All events were set as non-interaction hits. After a while here were the total event numbers from the GA reports:

As you can see in the report, there is a slight decrease in every step/delay. However, don’t use my example blindly. If your website is super heavy and Window Loaded fires after only 15 seconds (or even more), your drop-off might be much more significant.

Final words

You should definitely not overlook this trigger. If you are aware of how various scripts affect the page loading speed, you should definitely delay some of your tags at least to Window Loaded.

Also, if you plan to track certain website elements that are loaded with a certain delay, Window Loaded trigger might be a solution for that too. If you have a certain listener (implemented via Custom HTML tag), firing it on Window Loaded will greatly increase chances of having more accurate tracking data.

Got questions? Post them below.

Julius Fedorovicius

In Google Tag Manager Tips

1 COMMENT

Window Loaded is probably an underused trigger. For our sites, I try to have essential GA events on Page View while media stuff is pushed to Window Loaded. Better to have a fast loading website than a pixel hit with a user going away.