One tag, in the <head> of every page. That covers every human visitor.
Sites that want AI crawlers counted too — GPTBot, ClaudeBot, PerplexityBot — add a second, server-side step afterwards. It is a separate install because no browser tag can do it; AI crawlers need a second step below has it.
The snippet
The tag step of the setup — and, later, Settings → Install on the site — renders this with your own site key already substituted. Copy it from there rather than from this page, so you never have to hand-edit a placeholder.
<script
defer
data-website-id="ts_a1b2c3d4e5f6"
data-domain="example.com"
src="https://truestat.io/js/t.js"
></script>Four things about it worth knowing before you paste:
deferis deliberate. The script never blocks rendering and never runs before your page is parsed.It goes in
<head>, not before</body>. In<head>it is discovered earlier, and withdeferit still executes after parsing — you get the earlier fetch without the blocking.One tag, both jobs. You do not need to paste a second inline queue snippet for custom events. The queue ships inside the tag, so a
window.truestat("signup")call that fires before the script finishes loading is buffered and sent, not lost.It fails silently. If the collector is unreachable, the script does not throw, does not log by default, and does not affect your page.
On every page
The single most common install failure — across every platform — is the tag landing on the homepage only. If your platform has a global head or layout, that is where it goes. If you are pasting per-page, you have to paste it on every page.
Pick your platform
Installing TrueStat has a page each for:
Plain HTML — the baseline every other page assumes
Next.js — App Router and Pages Router
Squarespace, Wix, Ghost, Bubble and other head-field platforms
Google Tag Manager — needs a different snippet from the one above; the plain tag does not work reliably in GTM
AI crawlers need a second step
The tag above runs in a browser. An AI crawler is not a browser: GPTBot, ClaudeBot and PerplexityBot fetch your HTML and leave without running any JavaScript. However correctly the tag is installed, none of their visits reach it — and that is true of every analytics product, not just this one.
Counting them takes a few lines on the server that answers the request. On Next.js it is a package and two lines:
npm install @truestat/ai-crawl// proxy.ts — middleware.ts on Next 15 and earlier
import { truestat } from "@truestat/ai-crawl/next";
export const proxy = truestat("YOUR_SITE_KEY");
export const config = {
matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
};Your install page carries this as step 2, with your own site key already filled in, and a self-test button that confirms it reports.
Every platform's own version: Server-side tracking — Express, Django, Laravel, WordPress, Cloudflare Workers, and plain HTTP for anything else.
What it feeds: the AI & LLMs panel on your dashboard — which assistants read you, which pages they took, and whether that turned into visits.
It needs somewhere to run code on the request. A site on Webflow, Framer or Squarespace has no such place, and their install pages say so rather than leaving you looking for a setting that does not exist.
One thing to know up front
Ad blockers block analytics by hostname. A visitor running uBlock Origin
will not send you an event, because the request to truestat.io never
leaves their browser. This is true of every analytics product, ours included, and
it is the main reason your numbers will be lower than Google Analytics'.
You can recover most of that traffic by serving the script and the collector from your own domain. See Serving the script from your own domain. You do not have to do it now, and nothing else in this guide depends on it.