Skip to content

[Bug] External page tracking snippet broken — missing transport endpoint params #220

@parhumm

Description

@parhumm

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

  1. CDN URL uses trunk/: The snippet loads cdn.jsdelivr.net/wp/wp-slimstat/trunk/wp-slimstat.min.js while the internal CDN registration uses tags/{VERSION}/wp-slimstat.min.js. Using trunk risks version mismatch.
  2. Missing transport parameter: Without it, the primary transport is undefined, corrupting the fallback order.
  3. Missing ci parameter: External pages have no server-side content info injection.

Steps to Reproduce

  1. Go to WP Admin > Slimstat > Settings > Advanced > External Pages
  2. Copy the provided tracking snippet
  3. Create an HTML file on a different domain/server and paste the snippet before </body>
  4. Open the HTML file in a browser with DevTools > Network tab open
  5. Expected: XHR/Fetch request sent to WP site's tracking endpoint
  6. 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 of trunk/
  • Consider adding minimal ci with page info

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions