# Install the tracking script

One script tag. Everything else in VisitTrack builds on this.

VisitTrack tracks visitors with a single script tag. No npm package, no build step. Add it once to the page shell that wraps your whole site and you're done. Want nothing stored in the browser at all? Turn on [cookieless mode](https://visitrack.app/docs/cookieless).

## Add the tag

```
<script defer data-site="YOUR_SITE_ID" src="https://visitrack.app/tracker.js"></script>
```

### Next.js (App Router)

Use next/script in your root layout so it loads once across every route, rather than a raw tag per page.

```
import Script from "next/script";

export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>
        {children}
        <Script
          defer
          data-site="YOUR_SITE_ID"
          src="https://visitrack.app/tracker.js"
          strategy="afterInteractive"
        />
      </body>
    </html>
  );
}
```

## Check it's working

1. Open your site in a normal browser tab (not an incognito window with blockers on).
2. Open your dashboard. The 'waiting for your first pageview' banner disappears within a few seconds of the first real visit.
3. Still nothing? Open your browser's Network tab and look for a request to /api/collect. If it's missing, the script didn't load; if it's blocked, see below.

> **If your site sends a Content-Security-Policy** — Add https://visitrack.app to both script-src and connect-src. Without it the browser blocks the script silently — no error, no data, nothing in the dashboard.

> **Localhost is ignored on purpose** — The script no-ops on localhost, 127.0.0.1, *.local and file:// pages, so your own development traffic never pollutes real numbers. Add data-allow-local to the script tag if you specifically want to test locally.

## Next steps

- [Script configuration](https://visitrack.app/docs/script-configuration) — Every data- attribute, automatic events, excluding yourself, cross-domain.
- [Cookieless mode](https://visitrack.app/docs/cookieless) — Track without storing anything in the browser, and what it costs you.
