Cleaning Up Your Google Tag Manager (GTM) for Better Performance
GTM is a powerful tool that can become a performance nightmare. Learn how to audit, clean up, and optimize your GTM container.
Google Tag Manager makes it easy for marketers to add scripts without developers. Too easy. Over time, GTM containers accumulate unused tags, duplicate tracking, and heavy third-party scripts that can add 1-3 seconds to your page load.
How GTM Impacts Performance
GTM itself is relatively lightweight (~80KB), but each tag it fires can add:
- External scripts (analytics, pixels, chat widgets)
- DOM manipulation
- Network requests
- CPU processing
Common GTM Bloat
| Symptom | Typical Impact |
|---|---|
| 20+ tags firing on page load | +1-2s to TBT |
| Multiple analytics platforms | +500KB JavaScript |
| Chat widget tags | +300-800KB |
| A/B testing scripts | +200-500KB |
| Social media pixels (5+) | +500KB, dozens of requests |
| Abandoned experiment tags | Wasted resources |
Auditing Your GTM Container
Step 1: Export and Review
- Go to GTM → Admin → Export Container
- Open the JSON and count tags, triggers, and variables
- Document each tag's purpose
Step 2: Check Tag Firing
- In GTM, click "Preview" to enter debug mode
- Navigate your site
- Note which tags fire on each page
- Look for: tags that fire on every page but shouldn't, duplicate tags, tags for services you no longer use
Step 3: Measure Tag Impact
For each tag, check:
- How much JavaScript does it load?
- How many network requests does it make?
- Does it block the main thread?
- Is it actually collecting useful data?
Cleanup Checklist
Remove Dead Tags
- Tags for services you no longer use (old analytics, retired A/B tests)
- Duplicate tags (two Google Analytics snippets)
- Test tags that were never removed
- Tags for acquired/merged tools
Consolidate Tracking
Before:
- Google Analytics tag
- Google Ads conversion tag
- Google Ads remarketing tag
- Google Optimize tag
- 3 custom event tags
After:
- GA4 (replaces GA, handles conversions, events)
- Google Ads remarketing tag (1 tag for all campaigns)
Optimize Trigger Conditions
Before: Tag fires on "All Pages"
Trigger: All Pages
→ Chat widget loads on /terms-of-service (unnecessary)
After: Tag fires only where needed
Trigger: Page Path matches /pricing OR /contact OR /demo
→ Chat widget only loads on high-intent pages
Use Tag Sequencing and Priorities
Critical tags (analytics) should fire first. Non-critical tags (marketing pixels) can be delayed:
- Set tag firing priority (higher number = fires first)
- Use "Tag Sequencing" to load non-critical tags after critical ones
- Use "Once per page" trigger condition where appropriate
Performance-Oriented GTM Practices
1. Defer Non-Critical Tags
Use a custom trigger that fires after page load:
// Custom HTML tag that creates a trigger after 3s
<script>
setTimeout(function() {
window.dataLayer.push({ event: 'delayed_load' });
}, 3000);
</script>
Then trigger marketing pixels on the delayed_load event instead of All Pages.
2. Use Server-Side GTM
Server-side GTM moves tag processing to your server:
- Fewer scripts in the browser
- Better data control
- Reduced page weight
- Improved privacy compliance
3. Block Unnecessary Cookies/Scripts on First Load
Use a consent management trigger to prevent tags from firing until consent is given. This also improves initial performance.
4. Minimize Custom HTML Tags
Custom HTML tags can contain anything — including poorly written code:
- Review all custom HTML tags
- Replace with built-in tag types where possible
- Ensure custom code doesn't use
document.write() - Check for synchronous script loading
Before and After
| Metric | Before Cleanup | After Cleanup |
|---|---|---|
| GTM tags | 35 | 12 |
| Third-party requests | 45 | 15 |
| Page weight (JS) | 1.8MB | 600KB |
| TBT | 1500ms | 400ms |
| Lighthouse | 52 | 78 |
Monitor Tag Impact
New tags get added over time, recreating the bloat. BadPageSpeed monitors your page performance so you'll catch when a new tag degrades speed.
Ready to stop wasting ad spend?
Track your landing page performance, monitor Core Web Vitals, and calculate exactly how much slow pages cost you.
Start Free — No Credit Card