Skip links
View Categories

Cache plugin compatibility

1 min read

Page caches and JavaScript optimisers can break analytics by delaying, merging or caching scripts. Opti-Behavior handles the common ones automatically.

PluginHandled automatically
WP RocketJS combine, delay and defer exclusions, A/B cache-vary cookie
LiteSpeed CacheJS combine and defer exclusions, A/B vary cookie
W3 Total CacheJS minification of the tracker
Autoptimize / BreezeJS aggregation
PerfmattersDelay, defer and minify JS
WP Super Cache, Hummingbird, SG Optimizer and othersStandard no-optimise attributes

What Opti-Behavior does #

  • Trackers are already minified and loaded with defer, so optimisers have nothing to gain by touching them.
  • Tracker URLs change with each release, so caches and CDNs refresh them after an update.
  • When a cached page carries an old security token, the tracker refreshes it and sends the data again.
  • A/B tests register the opti_ab_v cookie so each variant is cached separately.
  • If a tracker seems silently blocked, the Setup check and an admin notice tell you, naming the likely plugin.

Manual exclusion (other optimisers) #

  1. Open your optimiser’s “exclude from delay / combine” setting.
  2. Add opti-behavior, optiBehavior, OptiBehavior, opti_behavior and _obq (exact case).
  3. Purge the cache and reload a page.

When a visitor is assigned a variant, a page cached for one variant must never be served to a visitor of another. The companion cookie opti_ab_v is registered automatically with WP Rocket and LiteSpeed so each variant has its own cached copy.

Troubleshooting #

  • No new sessions after enabling a cache – the page may be served as static HTML without the tracker: purge and add the exclusion.
  • Same A/B variant for everyone – your cache or CDN ignores opti_ab_v.
  • Stale dashboard numbers – object cache or edge cache; purge and wait for the next cycle.

Manual exclusion strings #

opti-behavior matches the tracker files. optiBehavior, OptiBehavior (Pro), opti_behavior and _obq match their inline configuration. Type them with this exact case: some optimisers are case-sensitive.

More questions #

Do I need to exclude anything by default? #

No, for the optimisers listed above.

Cloudflare APO or another edge cache? #

Supported. Purge after updates; for A/B tests, the edge cache must vary on the opti_ab_v cookie.

Expected result #

After purging, pages load the trackers and new visits appear; A/B variants differ between visitors.

FAQ #

After updating, tracking stopped. #

Purge the page cache and CDN once.

Does a CDN break tracking? #

No, as long as it forwards cookies for A/B test pages.

Leave a comment

Explore
Drag