Snippet: How to Install statpx Tracking on Your Site
Before any of statpx's dashboards can show you data, your site needs the tracking snippet installed. The Snippet page (snippet.php) is where you get that code, verify it's working, and control the optional attribution badge — all per site, since every site has its own unique tracking ID.
Getting the Snippet
Open a site and click Snippet in the sidebar. You'll see a two-line code block unique to that site:
The first line sets two global variables: window._stid (your site's tracking ID) and window._stendpoint (where track.js sends data). The second line loads track.js itself, asynchronously so it never blocks page rendering. Paste both lines before </head> or </body> — either works, since track.js waits for those globals regardless of load order. If you use a template system or CMS, add it once to your global layout so every page inherits it automatically.
Verifying the Install
After adding the snippet and visiting your own site once, come back to the Snippet page and click Verify Installation. statpx fetches your site and checks that the script is present and correctly configured, then reports success or a specific reason it couldn't find it — for example, the tracking ID not matching, or the script missing entirely. If verification fails, double-check that the snippet made it to the live page (not just a staging copy) and that no ad blocker or CSP rule is stripping the script.
Once a site is verified, statpx also rechecks periodically in the background and will notify you if the snippet ever stops responding — for example, after a site redesign accidentally drops it.
SPA Support
track.js automatically intercepts history.pushState calls, so single-page apps built with React, Vue, or similar frameworks get accurate pageview tracking on client-side route changes without any extra configuration — no manual event firing needed on every navigation. See tracking single-page apps for a deeper look at how this works and when you might still want a manual page-view call for edge cases like modal-based "pages."
The Optional Badge
Below the snippet, a checkbox lets you toggle a small "Analytics by statpx" badge that appends to the snippet code. It's a do-follow link back to statpx, and keeping it enabled is one way sites help keep statpx free — entirely optional, and toggling it updates the code block live so you can copy the exact version you want to ship.
<script>window._stRecord = true;</script> before the standard snippet lines.Common Mistakes to Avoid
- Copying an old tracking ID. Each site has its own unique ID — pasting one site's snippet onto another site's pages will attribute that traffic to the wrong site.
- Installing only on some pages. If the snippet is only in your homepage template, every other page goes untracked. Add it to the shared layout, not individual pages.
- Never running Verify Installation. It takes seconds and catches installation problems immediately instead of days later when you notice the dashboard is empty.
Install statpx in under two minutes
Two lines of code, no cookie banner required, and instant verification once it's live.
Start for free →The Bottom Line
The Snippet page is the one-time setup step every other statpx feature depends on: paste the two-line script, verify it, and you're tracking. SPA support and the optional badge round out the details, but the core steps are simple by design. Once installed and verified, head straight to Real-time to confirm your first visit is arriving, then move on to Stats as data accumulates.