Skip to main content

Install the tracker

The PureStats tracker is a small first-party style script served from https://purestats.io/pf.js. It records pageviews, custom events, no-code events, campaign parameters and optional cross-domain identifiers.

Basic script

Place this snippet in the <head> of every page you want to track:

<script defer src="https://purestats.io/pf.js" data-domain="example.com"></script>

Replace example.com with the canonical domain from PureStats. Consent mode, Do Not Track handling, excluded paths and cross-domain settings are loaded from Site Settings automatically.

Use the document <head> so the tracker initializes early without blocking rendering. The defer attribute lets the browser download the script while parsing the page and execute it after the document is ready.

Optional attributes

The tracker supports additional attributes for advanced setups, but they are not required for normal installations:

<script
defer
src="https://purestats.io/pf.js"
data-domain="example.com"
data-consent-mode="manual_required"
data-exclude-paths="/admin,/account"
></script>

Most sites only need data-domain. Use dashboard settings instead of hard-coded options when the setting should be managed centrally or by non-developers.

Single-page apps

For React, Vue, Next.js client transitions or other SPA routing, PureStats listens for history changes and can record virtual pageviews. See SPA routing for framework notes.

Verify the first hit

After deployment, open your site in a normal browser session and check Site Health. If your own visit is filtered out because of bot, spam, consent or path rules, use another browser profile or temporarily adjust the setting.