Skip to content

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

  1. Create an account and add your website's domain.
  2. Copy your snippet from the dashboard (or below, when you're signed in) and replace the domain with yours.
  3. Paste it inside the <head> of every page, or into your site-wide template.
HTML
<script defer data-domain="example.com" data-account="YOUR-ACCOUNT-NUMBER" src="https://statrak.com/js/script.js"></script>

Copy your own snippet from the dashboard (Account → Your tracking code, or any site's settings): it carries your account number, which verifies your sites and adds them to your account automatically. Without it, sites are counted but never verified.

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

app/layout.tsx
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

Every account has an account number (find it under Account → Your tracking code). Put the snippet with your number in a shared template or parking page, and leave out data-domain, so StaTrak uses each page's hostname. One snippet then works everywhere:

Shared template
<script defer data-account="YOUR-NUMBER" src="https://statrak.com/js/script.js"></script>

When a site with your snippet gets its first visitors, StaTrak checks that its homepage really carries your number (on arrival or during a half-hourly scheduled run) and adds it to your account, verified as yours. Remove any you don't want; they won't come back. Prefer to approve each one? Turn off Add new sites automatically under Account, and new sites wait under Sites found by your tracking code on your dashboard.

You can also add sites yourself in bulk from Add website → Bulk import by pasting one domain per line.

Verify you own a domain

Verifying proves a website is yours. Until a domain is verified, another account could add it too. Once you verify, its pageviews come only to you and nobody else can claim it. Use any of these methods:

Tracking script (easiest)

Install the snippet from your dashboard. It carries your account number in a data-account attribute:

HTML
<script defer data-domain="example.com" data-account="YOUR-NUMBER" src="https://statrak.com/js/script.js"></script>

Put the snippet in your site's <head> (for React, Vue and Lovable apps, in index.html). Once visits with your account number arrive, StaTrak checks the site and verifies it, usually within an hour. It looks in the HTML of your homepage and recently visited pages, and in your site's own script files, so a snippet added from your app's code counts too. A snippet without a number, or with another account's number, doesn't count. If your host blocks automated visits (you'll see "blocked" in Site settings → Ownership), use the DNS record or statrak.txt instead. Snippets with a data-verification code from before account numbers keep working.

DNS record

At your domain registrar or DNS provider, add a TXT record on the domain itself (host @) with the value shown in Site settings → Ownership. This works even if you load the script through a tag manager.

TXT record
statrak-verification=YOUR-CODE

Text file

Can't change the page's HTML? Upload a plain text file named statrak.txt so it opens at https://example.com/statrak.txt, containing this line:

statrak.txt
statrak-account=YOUR-NUMBER

We check unverified sites for all three about once an hour, so there's nothing else to do. To check straight away, click Verify now. DNS changes can take up to an hour to appear. Once verified, the site stays verified.

The “Analytics by StaTrak” footer link

StaTrak is free. In return, the script adds a small “Analytics by StaTrak” link to your site, which helps other site owners find us. It is a plain text link: it sets no cookies and collects nothing.

Light footer · © Your Website

Analytics by StaTrak

Dark footer · © Your Website

Analytics by StaTrak

Where it appears

  1. Inside an element with the data-statrak-badge attribute, if your page has one.
  2. Otherwise, at the bottom of your page's last <footer> element.
  3. If there is no footer, centred at the very end of the page.
Choose the position
<div data-statrak-badge></div>

Matching your design

By default the link uses your footer's text colour at reduced opacity. To force a colour, add data-badge="dark" (light text for dark footers) or data-badge="light" (dark text for light footers) to the script tag:

Dark footer
<script defer data-domain="example.com" data-badge="dark" src="https://statrak.com/js/script.js"></script>

Custom events

Track sign-ups, downloads or purchases with one function call. Events show up as goals in your dashboard.

JavaScript
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.

Feedback widget

Let visitors report a bug, suggest an improvement, send feedback, ask a question or contact you, without leaving the page. Turn it on in Site settings → Feedback widget (the site must be verified). Your tracking snippet then shows a small button; there's no extra code to install.

Each message arrives in your Issues list and by email, with the page, browser, device, screen size, location and the pages the visitor viewed in that visit, so you can see how they got there. Give each one a priority, mark it in progress, add notes, tick it off when it's done or ignore it. Visitors see what's included before they send. No cookies are used, and visits can't be linked across days.

Choose the button text, colour and position, which kinds of message to accept, and an optional question of your own, such as “What stopped you from completing your purchase?”. A webhook can also receive each message as JSON. To open the widget from your own link or button:

HTML
<button onclick="statrakFeedback.open('bug')">Report a problem</button>

The Insights tab in Issues points out pages that collect several reports, what those visitors have in common, and how the pages perform. To hide the widget on one page, add data-feedback="off" to that page's snippet.

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:

Browser console
localStorage.setItem("statrak_ignore", "true");

Verify installation

Visit your website in a normal browser window, then open its dashboard in StaTrak. The visit shows up within 30 minutes. Use the Verify installation button on a new site to check that the script is found on your homepage.