crossorigin="anonymous" and your website id. Put it in the one place your framework renders on every page, and render it once. Each recipe also sets data-domains, so preview builds and local development send nothing.
Replace YOUR-WEBSITE-ID with the id from your project’s Setup page, and example.org,www.example.org with the exact hostnames you serve in production.
Keep previews and local development out
The tracker readsdata-domains as a comma-separated list of hostnames. When it is set, the tracker sends nothing unless location.hostname is exactly one of them. Without it, two things go wrong:
- Previews on a subdomain are counted. The collect endpoint accepts events from your website’s domain and every subdomain of it, so a preview at
preview.example.orgpasses the origin check and adds to your production numbers. - Previews on another domain and
localhostare flagged. They fail the origin check asorigin_mismatch. They are never counted, but they fill your Flagged, not counted card with your own traffic.
www.example.org and example.org separately if both serve pages.
- HTML
- Next.js
- React (Vite)
- Astro
- SvelteKit
- Nuxt
Paste the tag into the
<head> of every page, or of the shared template your pages are built from.index.html
Check the result
Load a production page, open the developer tools and confirm two things: the rendered<script> element carries integrity and crossorigin, and the Network tab shows a POST to https://t.lumenstat.com/e with a response that contains a cache token. Then reload Setup and look at Is data arriving?. If something is off, the troubleshooting list in Add the tracker covers each failure.
On a preview or on localhost, the Network tab should show no request to /e at all. That is data-domains working.