Lazy load Google Tag Manager so your content loads first
Google Tag Manager is what loads Google Analytics and ad pixels on your site. With lazy loading, it only loads once someone scrolls, clicks, taps or moves the mouse. Until then your page loads without it. Enter your GTM ID and copy the finished script.
Replace your existing GTM snippet in the head (the top section of your page’s code) with this script. Check in GTM’s preview mode that your tags still fire.
You can also take tracking out of the browser completely. With server-side tracking, the tools run on a server instead of on your page.
See server-side trackingWhat the script does for you
Your visitors see your content first. Tag Manager only loads once someone does something on the page.
Your page has loaded before Tag Manager starts
The browser loads only your content first. That shortens load time and usually improves the scores Google uses to rate page speed (Core Web Vitals).
You can add it in a few minutes
Enter your GTM ID, and the tool generates a script that’s ready to use right away.
Works on every website
The script runs on WordPress, Webflow, Shopify and any other website where you can add code to the head.
How to add the script
After three steps, your Tag Manager only loads once someone does something on the page.
- 01Enter your IDYou’ll find your GTM ID at the top right of your Tag Manager container. It starts with GTM-.
- 02Replace the snippetSwap the existing GTM snippet in the head of your website for the new script. If the old one stays, GTM loads twice.
- 03Check in previewOpen GTM’s preview mode, scroll once and check that your tags fire.
You can also skip Tag Manager in the browser
With Cloudflare Zaraz, Cloudflare’s own tag manager, Google Analytics and the Meta Pixel run on Cloudflare, and the browser only loads a small script from your domain.
Zaraz vs Tag Manager comparedQuestions about lazy loading Tag Manager
Some, yes. Anyone who opens the page and leaves without scrolling, clicking or tapping never triggers Tag Manager. For paid ad landing pages, where every visit counts, lazy loading is the wrong choice.
The script only moves the moment Tag Manager loads. If your banner itself runs through Tag Manager, it appears after the first interaction. You keep controlling consent through your banner and Google’s Consent Mode in GTM.
No. The script is created in your browser. Your ID doesn’t go to any server, not even mine.
Yes, with Cloudflare Zaraz. Google Analytics and the Meta Pixel then run on Cloudflare, and the browser only loads a small script from your own domain.
