Getting started

Install the tracker

One script tag in the <head>. It is about 2 KB gzipped, loads deferred, and never blocks rendering.

The script tag

Find your site ID in Settings, then add:

index.html
<script defer src="https://t.thunderstats.com/ts.js" data-site-id="YOUR_SITE_ID"></script>

Pageviews are sent on load and on every pushState / replaceState / popstate, so single-page apps work without extra configuration.

Optional auto-tracking

Add these attributes to the same script tag to collect more without writing code.

AttributeWhat it does
data-track-clicksFires Outbound Click for links to other domains and File Download for common file extensions (pdf, zip, dmg, docx, mp4, and similar).
data-track-scrollFires Scroll Depth once per page at 25%, 50%, 75%, 90% and 100%.
data-track-404Fires a 404 event when the page title or first heading looks like a not-found page. Powers the Pages → Not found report.
index.html — with auto-tracking
<script defer src="https://t.thunderstats.com/ts.js"
        data-site-id="YOUR_SITE_ID"
        data-track-clicks data-track-scroll></script>

Content Security Policy

If your site sends a CSP header, allow the tracker host:

CSP directives
script-src  https://t.thunderstats.com
connect-src https://t.thunderstats.com
No external script allowed at all?

The dashboard can generate an inline build of the tracker that needs only connect-src. Open Settings and switch the snippet to Inline (CSP-safe).

WordPress

Install the ThunderStats plugin, then connect it from Settings → ThunderStats. The plugin offers two modes:

  • JavaScript — injects the script tag for you, with checkboxes for the auto-tracking options above.
  • Server-side — sends pageviews from PHP with no JavaScript at all. Immune to ad blockers, and nothing is added to the page. Requires an API key.

Server-side mode uses the same endpoint documented in the HTTP API.

Verifying the install

Open your site in a normal browser tab, then check Realtime in the dashboard. Your visit should appear within a few seconds.

Not seeing anything?

The most common causes are an ad blocker on your own machine (try a private window or your phone), a CSP that blocks the request, or a site ID that does not match the one in Settings. Server-side tracking avoids the first two entirely.

Next: Custom events →