Troubleshooting

Exclude SlimStat From Caching and Minification

Applies to SlimStat 5.5.0 · checked

SlimStat needs two things excluded from caching and minification: the tracker file wp-slimstat.min.js in the plugin root, and the endpoint each hit posts to. Exclude both from JavaScript minification, concatenation, deferral and page caching, then set Tracking Mode to Client under SlimStat > Settings > General, because Server mode cannot see a cached page.

Caching or optimisation pluginSetting to changeValue to add
W3 Total CacheMinify > Never minify the following JS fileswp-content/plugins/wp-slimstat/wp-slimstat.min.js
WP RocketFile Optimization > Excluded JavaScript Files/wp-content/plugins/wp-slimstat/(.*).js
LiteSpeed CachePage Optimization > JS Settings > JS Excludeswp-slimstat.min.js
AutoptimizeJavaScript Options > Exclude scripts from Autoptimizewp-slimstat.min.js
WP Super CacheNo JavaScript optimiser to configureSet Tracking Mode to Client
CloudflareSpeed > Optimization > Rocket LoaderOff

Client mode is mandatory once pages are cached

SlimStat ships javascript_mode set to on, which the settings screen labels Client, and a cached site has no alternative. Server mode hooks the slimtrack() callback onto the WordPress wp action at priority 5, and a page served from disk or from an edge network runs no PHP, so the wp action never fires for those visitors.

  1. Open SlimStat > Settings > General in the WordPress admin.
  2. Find Tracking Mode in the Tracker section.
  3. Switch the toggle from Server to Client.
  4. Click Save Changes.
  5. Purge the caching plugin so every page is rebuilt with the tracker tag.

SlimStat flags the mismatch on its own. When wp-content/advanced-cache.php exists and Tracking Mode is still Server, the reports screen prints “A caching plugin might be enabled on your website”; the notice_caching setting, on by default, controls that warning. Tracking Mode, Tracking Request Method, Enable CDN and the Real-time screen all belong to the free SlimStat plugin.

The tracker file: wp-slimstat.min.js at the plugin root

SlimStat registers /wp-content/plugins/wp-slimstat/wp-slimstat.min.js under the script handle wp_slimstat, and the file ships already minified: 75 KB against 112 KB of readable source. A second minification pass therefore gains nothing and risks breaking the tracker, so exclude that path from minification and from concatenation in every optimisation plugin running on the site.

Two settings move the tracker URL somewhere a wp-slimstat.min.js rule will never match:

  • Enable CDN, under SlimStat > Settings > Tracker > Performance, serves the tracker from https://cdn.jsdelivr.net/wp/wp-slimstat/tags/<version>/wp-slimstat.min.js. Exclude the cdn.jsdelivr.net host rather than a local path.
  • Ad-Blocker Bypass, chosen under Tracking Request Method, serves the same file from a 32-character hexadecimal name at the site root, in the form /{hash}.js. No exclusion containing the string wp-slimstat matches that URL.

Concatenation carries a second risk. wp_localize_script prints the SlimStatParams object in an inline script immediately before the tracker tag, so an optimiser that drops or reorders inline scripts leaves the tracker with no endpoint to call; the slimstat_js_params filter documents what that object carries. SlimStat already adds defer to its own tag, so a “load JavaScript deferred” option gains nothing here.

The tracking endpoint: which URL to leave uncached

Tracking Request Method, under SlimStat > Settings > General, decides where the browser posts each hit, and the shipped default is Admin-AJAX. Page-cache rules, delayed-JavaScript rules and URL rewrites each break that request in a different way, so exclude the URL the site actually uses from all three kinds of rule.

Tracking Request MethodURL the browser posts toNote
Admin-AJAX (default)/wp-admin/admin-ajax.phpAJAX action name is slimtrack
REST API/wp-json/slimstat/v1/hitRoute registered for POST only
REST API, plain permalinks/index.php?rest_route=/slimstat/v1/hitAutomatic query-string fallback
Ad-Blocker Bypass/request/{hash}/Served by a WordPress rewrite rule

Fallback between the three methods is always on: when the selected Tracking Request Method fails, SlimStat tries the next available one. A half-finished exclusion therefore shows up as partial or slow tracking rather than as silence, which is why the Real-time check below beats reading the settings screen.

WP Rocket, LiteSpeed, Autoptimize and Rocket Loader

WP Rocket repeats the same Excluded JavaScript Files box under Minify JavaScript files, under Load JavaScript deferred and under Delay JavaScript execution, and each box is read only by its own parent option. Add /wp-content/plugins/wp-slimstat/(.*).js to whichever of the three parent options is switched on.

  • LiteSpeed Cache: add wp-slimstat.min.js to JS Excludes, and to JS Deferred Excludes when Load JS Deferred is on.
  • Autoptimize: add wp-slimstat.min.js to the comma-separated “Exclude scripts from Autoptimize” field under JavaScript Options.
  • WP Super Cache: WP Super Cache ships no JavaScript optimiser, so Tracking Mode plus a full cache purge is the whole fix.
  • Cloudflare Rocket Loader: turn Rocket Loader off under Speed > Optimization. SlimStat adds defer to its script tag but no data-cfasync="false" attribute, so Rocket Loader has no per-script opt-out to honour here.

Confirm the tracker is firing again

SlimStat > Real-time is the fastest check after a cache purge, and Auto Refresh reloads its Access Log every 60 seconds by default, set under Settings > Reports. Open a tracked page in a private window, then reload Real-time. A row appearing there proves both halves worked: the tracker file loaded, and the endpoint accepted the request.

If no row appears, open the browser network panel and look for the POST to /wp-admin/admin-ajax.php, or to whichever URL the table above lists for the configured method. A 404 or a redirect points at the endpoint exclusion, while a JavaScript error thrown inside wp-slimstat.min.js points at the minifier. SlimStat Is Not Recording Visits works through the tracker error code SlimStat stores, and Server-Side Tracking covers what Client mode trades away.

SlimStat Pro — plans start at $3.25/mo