Documentation
Install StaTrak
One script tag, no cookies, no configuration. Here's how to add StaTrak to your website and get the most out of it.
Quick start
- Create an account and add your website's domain.
- Copy the snippet below, replacing the domain with yours.
- Paste it inside the <head> of every page, or into your site-wide template.
<script defer data-domain="example.com" src="https://statrak.com/js/script.js"></script>The script loads with defer, so it never blocks your page from rendering. Pageviews in single-page apps are tracked automatically through the History API.
Platform guides
WordPress
Go to Appearance → Theme File Editor → header.php (or use a header-scripts plugin) and paste the snippet just before</head>.
Shopify
Open Online Store → Themes → Edit code → theme.liquid and paste the snippet before </head>.
Webflow, Squarespace, Wix
Paste the snippet into the site-wide custom code setting for the head section, then publish.
Next.js
import Script from "next/script";
export default function RootLayout({ children }) {
return (
<html lang="en">
<head>
<Script defer data-domain="example.com" src="https://statrak.com/js/script.js" />
</head>
<body>{children}</body>
</html>
);
}React, Vue, Svelte and other SPAs
Add the snippet to your index.html. Route changes are detected automatically.
Tracking hundreds of sites
If many websites share a template or parking page, leave out data-domain. StaTrak then uses the page's hostname, so one snippet works everywhere:
<script defer src="https://statrak.com/js/script.js"></script>Pageviews from domains that aren't in your account are ignored. Add sites in bulk from Add website → Bulk import by pasting one domain per line.
Custom events
Track sign-ups, downloads or purchases with one function call. Events show up as goals in your dashboard.
window.statrak?.("Signup", { props: { plan: "growth" } });Event properties must not contain personal data such as emails or names.
Search keywords
Search engines strip queries from referrers. To see keywords, open your site in StaTrak, go to Site settings → Integrations and connect Google Search Console. Aggregated queries with clicks, impressions, CTR and position then appear in the Search keywords panel.
Exclude your own visits
Run this once in your browser's console on your site. It sets a flag only in your browser, so your visits are ignored:
localStorage.setItem("statrak_ignore", "true");Verify installation
Visit your website in a normal browser window, then open its dashboard in StaTrak. The live visitor count updates within a few seconds. Use the Verify installation button on a new site to check that the script is found on your homepage.
