This article covers the most common conflicts between GTM Kit and the cache, performance, and consent plugins it shares space with on a typical WordPress stack.
Symptoms
- Tracking works on staging or with caching off, but breaks on production.
- Tracking works for new visitors but breaks for repeat visitors who hit the cache.
- The GTM container snippet appears but
window.dataLayeris empty. - Events appear sometimes and not other times in a way that correlates with whether the page was cached.
How to triage fast
Disable plugins in this order until tracking starts working:
- Page cache plugin (WP Rocket, W3 Total Cache, LiteSpeed Cache, WP Super Cache).
- Asset optimizer (Autoptimize, Perfmatters, Async JavaScript, Hummingbird).
- CMP plugin (Cookiebot, Complianz, CookieYes, Cookie Information).
- CDN-level caching (Cloudflare auto-minify, Bunny.net optimization).
The plugin that, when disabled, causes tracking to start working is the conflicting plugin. Then re-enable it and configure it to leave GTM Kit alone.
Specific conflicts and fixes
WP Rocket
Symptom: Container loads but data layer is empty, or events fire but with stale data on cached pages.
Root cause: WP Rocket’s “Delay JavaScript Execution” can defer GTM Kit’s data-layer enqueue past the point where the integration scripts need it. WP Rocket also has its own GTM integration option that can fight with GTM Kit’s snippet.
Fix:
- Open WP Rocket, File Optimization, JavaScript.
- Under Delay JavaScript Execution, add these patterns to the exclusion list:
gtm-kitgoogletagmanager.comdataLayer
- Under Combine JavaScript Files, exclude the same patterns.
- Disable WP Rocket’s own GTM integration (if you had it enabled) since GTM Kit is now handling it.
- Clear cache.
W3 Total Cache
Symptom: Container snippet missing on cached pages.
Root cause: Aggressive minification can strip or move GTM Kit’s inline scripts.
Fix:
- Performance, General Settings, Minify: set Minify Mode to Manual.
- Performance, Minify, JS: do not include GTM Kit’s scripts. They are inline; you generally do not minify inline scripts in W3TC.
- Clear all caches.
LiteSpeed Cache
Symptom: Snippet appears in source but events fail intermittently.
Root cause: LiteSpeed’s “Defer JS Loaded” or “Localize Resources” can fetch a stale copy of googletagmanager.com/gtm.js and serve it from your origin, breaking the live GTM container.
Fix:
- LiteSpeed Cache, Page Optimization, Localization: turn off Localize Resources for
googletagmanager.com. - JS Settings: do not load deferred or async on the GTM script.
- Purge all caches.
Autoptimize
Symptom: Snippet appears but data layer is empty or missing entries.
Root cause: Aggressive JS aggregation can move GTM Kit’s data-layer enqueue out of order with the container snippet.
Fix:
- Settings, Autoptimize, JS, CSS, HTML.
- Under JavaScript Options, add to Exclude scripts from Autoptimize:
gtm-kitgtm.jsdataLayer
- Save and empty cache.
Perfmatters
Symptom: GTM tags fire but with stale or missing data layer values.
Root cause: Perfmatters’ Script Manager can disable GTM Kit’s scripts on specific page types if you have used it to slim pages aggressively.
Fix:
- Perfmatters, Script Manager.
- On a problem page, find the GTM Kit script entries.
- Confirm they are set to Loaded (not disabled).
Cookiebot
Symptom: Container loads but data layer pushes are silently suppressed.
Root cause: Cookiebot scans the page for scripts and prefixes ones it does not recognize with data-cookieconsent="ignore". If GTM Kit’s helper scripts get scanned and gated, events stop pushing.
Fix:
- In GTM Kit, go to Settings → Consent → CMP script attributes and confirm Cookiebot is on. This adds
data-cookieconsent="ignore"to GTM Kit’s helper scripts so Cookiebot’s auto-blocking lets them through. Upgraders from pre-2.10 already have this on by default. - If pushes are still blocked, in Cookiebot’s WordPress plugin go to Settings, Advanced, Auto-blocking and set it to off, or add a domain exclusion for your own site’s hostname.
Complianz
Symptom: Both GTM Kit and Complianz emit Consent Mode v2 defaults, causing the second-loaded one to override the first.
Fix: Turn off Default Consent State in GTM Kit. See Coexist with a CMP.
Cloudflare
Symptom: Snippet appears in source on the origin but is missing on Cloudflare-cached pages.
Root cause: Cloudflare’s Auto Minify on HTML occasionally breaks inline scripts with unusual whitespace or comments.
Fix:
- Cloudflare dashboard, Speed, Optimization: turn off Auto Minify, HTML.
- Purge cache: Caching, Configuration, Purge Everything.
General principle: order of operations
The chain GTM Kit relies on is:
gtag('consent', 'default', ...)(if Consent Mode is on).- GTM container
<script>initializeswindow.dataLayer. - GTM Kit’s helper scripts push events to
window.dataLayer.
If anything in your stack reorders, defers, or removes one of those steps, the chain breaks. The fix is always: configure the offending plugin to leave the GTM Kit script files and the GTM container script alone.