-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Summary
The external tracking snippet shown on Settings > Advanced > External Pages generates JavaScript that only sets SlimStatParams.ajaxurl. However, the current JS tracker's processQueueItem() function builds its transport endpoint map from ajaxurl_rest, ajaxurl_ajax, and ajaxurl_adblock — never from plain ajaxurl. With none of these set, trySend() skips all transport methods and silently fails.
External page tracking is completely broken for all users.
Root Cause
The snippet in admin/config/index.php:369 was written for the legacy single-endpoint AJAX architecture. When the tracker was refactored to use the multi-transport system (rest / ajax / adblock_bypass with separate endpoint URLs), the external snippet was never updated.
Causal Chain:
User embeds external tracking snippet on non-WP page
→ wp-slimstat.min.js loads and calls sendPageview()
→ processQueueItem() builds endpoints map:
{ rest: params.ajaxurl_rest, // undefined
ajax: params.ajaxurl_ajax, // undefined
adblock_bypass: params.ajaxurl_adblock } // undefined
→ trySend() skips all transports (line 400: if (!url) return trySend(i + 1))
→ callback(false) — no tracking request is ever sent
Additional Issues
- CDN URL uses
trunk/: The snippet loadscdn.jsdelivr.net/wp/wp-slimstat/trunk/wp-slimstat.min.jswhile the internal CDN registration usestags/{VERSION}/wp-slimstat.min.js. Usingtrunkrisks version mismatch. - Missing
transportparameter: Without it, the primary transport isundefined, corrupting the fallback order. - Missing
ciparameter: External pages have no server-side content info injection.
Steps to Reproduce
- Go to WP Admin > Slimstat > Settings > Advanced > External Pages
- Copy the provided tracking snippet
- Create an HTML file on a different domain/server and paste the snippet before
</body> - Open the HTML file in a browser with DevTools > Network tab open
- Expected: XHR/Fetch request sent to WP site's tracking endpoint
- Actual: No request sent — tracker silently fails
Code References
| File | Lines | Description |
|---|---|---|
admin/config/index.php |
369 | External snippet generation — only sets ajaxurl |
wp-slimstat.js |
321 | Endpoint map reads ajaxurl_rest, ajaxurl_ajax, ajaxurl_adblock |
wp-slimstat.js |
399-400 | trySend() skips when endpoint URL is falsy |
wp-slimstat.php |
1120-1126 | enqueue_tracker() shows full params the tracker expects |
wp-slimstat.php |
1211 | CDN mode uses versioned tags/{VERSION}/ path |
Proposed Fix Direction
Update the snippet in admin/config/index.php:369 to include:
transport: "ajax"— external pages should use AJAX (no REST nonce available cross-origin)ajaxurl_ajax: "{admin-ajax.php URL}"— transport-specific endpoint- Use versioned CDN URL (
tags/{VERSION}/) instead oftrunk/ - Consider adding minimal
ciwith page info