Don't have one? Create one ↗
How web tracking really works

Lesson 1 of 7

The Page-Load Lifecycle

When a browser opens a page it requests the HTML, parses it into the DOM, and runs scripts as it goes. GTM is added high in the page and loads asynchronously, then fires a sequence of built-in events as the page progresses.

1Request2Parse HTML3gtm.js4gtm.dom5gtm.load

The built-in events

  • gtm.js, the container has loaded and can start firing.
  • gtm.dom, the DOM is ready (the Page View / DOM Ready trigger).
  • gtm.load, the window has fully loaded, images and all.

Timing matters because a tag that reads page content must fire after that content exists, and a tag that needs page context needs that context pushed before it runs. Choosing the right moment is half of getting a tag to work.

Key takeaway

GTM fires gtm.js, then gtm.dom, then gtm.load. Match each tag to the moment its data is actually available.