GTM Container Audits & Performance

How to audit a bloated GTM container and reduce its effect on site speed.

  • A GTM container slows your site and hurts INP because dead and unneeded tags pile up over time; audit what actually fires and delete the rest.
  • Export the container first as a backup, then remove paused tags, tags with no trigger, and tags tied to pages or events that no longer exist.
  • Use Preview on key page types and conversions to compare what fires against your full tag list, and check where data goes: old Universal Analytics tags, pixels for inactive ad accounts, trial tools, and duplicate tags are all dead weight.
  • Delete unused triggers and variables, and assign an owner to every remaining tag. If nobody can say who uses a tag's data, pause it for 30 days, then delete it.
  • The container script is small; the real INP cost is what it loads and runs on the main thread (Custom HTML, vendor libraries, click/scroll listeners).
  • To measure GTM's impact, record in the Chrome DevTools Performance panel, then block googletagmanager.com under Network request blocking and record again. The difference is your container's cost.
  • Common culprits and fixes: sample session replay/heatmap tools, load chat widgets on click or after a delay, limit All Pages tags and fire non-critical tags on Window Loaded, remove unused click/scroll triggers, and replace document.write or sync scripts with async versions or templates.
  • Server-side tagging doesn't fix a bloated web container. It only helps if you actually remove vendor scripts from the browser and send their data from the server.
  • Under a strict CSP, use a fresh server-generated nonce per page load (not on cached pages), the nonce-aware GTM snippet, and allow each vendor's script-src, img-src and connect-src domains. Custom JavaScript variables need 'unsafe-eval', so replace them with built-in variables or templates where possible.
  • Keep the container small and maintainable with consistent naming (platform - type - detail), folders, owner and date in tag notes, descriptive version notes, and an audit about twice a year.

A GTM container collects dead tags over time, and a bloated container slows the site and hurts INP.

If you want a faster site and a container you can trust, audit what actually fires and delete the rest. A container gets slow because nobody removes anything.

Find the Dead Tags

  1. Export the container. Go to Admin > Export Container so you have a backup and a full list of tags, triggers and variables.
  2. Remove what can’t fire. Paused tags, tags with no trigger, and tags on triggers for pages or events that no longer exist.
  3. Check what does fire. Run Preview on your main page types and conversions. Note every tag that fires and compare it with the list.
  4. Check where the data goes. A tag can fire and still be dead. Old Universal Analytics tags, pixels for ad accounts that stopped spending, and trial tools nobody logs into.
  5. Find duplicates. Two GA4 config tags, the same pixel installed by a template and again by Custom HTML.
  6. Clean up what’s left behind. Delete triggers and variables that no tag uses.

Ask an owner for each remaining tag. If nobody can say who uses the data, pause it for 30 days, then delete it.

Measure GTM’s Effect on INP

The container script itself is small. The cost is what it loads and runs: every Custom HTML tag, every vendor library, and every listener attached to clicks and scrolls runs on the main thread, and that’s what delays interactions.

  1. Open Chrome DevTools, go to the Performance panel and record while you click around the page.
  2. Look at the slow interactions and expand the long tasks. Scripts are grouped by domain, so third party tags are easy to see.
  3. Block googletagmanager.com under Network request blocking and record again. The difference is your container.
  4. Re-enable it and pause tags one group at a time in a Preview workspace to find the heavy ones.

The usual causes:

Cause Fix
Session replay & heatmap tools Run them on a sample of pages or sessions, not every page view.
Chat widgets Load on click or after a delay, not on page load.
Everything firing on All Pages Limit each tag to the pages that need it, and fire non-critical tags on Window Loaded.
Click and scroll listeners Remove triggers nothing uses. Each one adds work to every interaction.
Custom HTML with document.write or sync scripts Replace with an async version or a template.

Server-Side Tagging Doesn’t Fix It Alone

Moving to a server container doesn’t make a bloated web container fast. The browser still loads the container and runs the tags that are in it. It only helps when you remove vendor scripts from the browser and send their data from the server instead. If the same pixels still load on the page, nothing changed.

GTM Under a Content Security Policy

A strict CSP blocks GTM until you allow it with a nonce:

  1. Generate a new nonce on the server for every page load, and send it in the script-src directive.
  2. Add the same nonce to the GTM snippet’s script tag.
  3. Use the nonce-aware version of the snippet from Google’s CSP guide, which passes the nonce on to the scripts GTM injects. Without it, Custom HTML tags are blocked.
  4. Add each vendor’s domains to the policy. Every tag in the container needs its own script-src, img-src and connect-src entries.
Content-Security-Policy: script-src 'nonce-{RANDOM}' https://www.googletagmanager.com; img-src https://www.googletagmanager.com; connect-src https://www.google-analytics.com

Two things catch people out. A cached page serves the same nonce to every visitor, so the nonce has to be generated where the page isn’t cached. And Custom JavaScript variables need 'unsafe-eval', so replace them with built-in variables or custom templates if you can’t allow it.

A CSP is another reason to keep the container small. Every tag you delete is a domain you don’t have to allow.

Keep It Small

  • Name everything the same way: platform, type, then detail, like GA4 - Event - generate_lead.
  • Use folders by platform or team.
  • Write the owner and date in the tag notes.
  • Describe every version when you publish, so changes can be traced.
  • Audit on a schedule. Twice a year is enough for most sites.

I go into the naming and structure I use in Google Tag Manager patterns.