---
title: "Conflicts with cache and consent plugins"
date: 2026-05-04
author: "GTM Kit"
---

# Conflicts with cache and consent plugins

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.dataLayer` is 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:

1. Page cache plugin (WP Rocket, W3 Total Cache, LiteSpeed Cache, WP Super Cache).
2. Asset optimizer (Autoptimize, Perfmatters, Async JavaScript, Hummingbird).
3. CMP plugin (Cookiebot, Complianz, CookieYes, Cookie Information).
4. 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:**

1. Open **WP Rocket, File Optimization, JavaScript**.
2. Under **Delay JavaScript Execution**, add these patterns to the exclusion list:

- `gtm-kit`
- `googletagmanager.com`
- `dataLayer`

1. Under **Combine JavaScript Files**, exclude the same patterns.
2. Disable WP Rocket’s own GTM integration (if you had it enabled) since GTM Kit is now handling it.
3. 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:**

1. **Performance, General Settings, Minify**: set Minify Mode to Manual.
2. **Performance, Minify, JS**: do not include GTM Kit’s scripts. They are inline; you generally do not minify inline scripts in W3TC.
3. 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:**

1. **LiteSpeed Cache, Page Optimization, Localization**: turn off **Localize Resources** for `googletagmanager.com`.
2. **JS Settings**: do not load deferred or async on the GTM script.
3. 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:**

1. **Settings, Autoptimize, JS, CSS, HTML**.
2. Under **JavaScript Options**, add to **Exclude scripts from Autoptimize**:

- `gtm-kit`
- `gtm.js`
- `dataLayer`

1. 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:**

1. **Perfmatters, Script Manager**.
2. On a problem page, find the GTM Kit script entries.
3. 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:**

1. 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.
2. 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](https://gtmkit.com/documentation/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:**

1. **Cloudflare dashboard, Speed, Optimization**: turn off **Auto Minify, HTML**.
2. Purge cache: **Caching, Configuration, Purge Everything**.

## General principle: order of operations

The chain GTM Kit relies on is:

1. `gtag('consent', 'default', ...)` (if Consent Mode is on).
2. GTM container `<script>` initializes `window.dataLayer`.
3. 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.

## Related articles

- [The container snippet is not loading](https://gtmkit.com/documentation/the-container-snippet-is-not-loading/)
- [Events are not appearing in GTM Preview](https://gtmkit.com/documentation/events-are-not-appearing-in-gtm-preview/)
- [Coexist with a CMP](https://gtmkit.com/documentation/coexist-with-a-cmp/)