Skip to main content

Installing

Install on Lovable, Bolt, v0 or Replit

These builders generate the code, so the install is a prompt rather than a paste.

These builders generate the code, so the install is a prompt rather than a paste. Your site's install page renders the prompt with your real site key already in it — copy it from there.

The prompt

Add the TrueStat analytics script to my site.

Insert this exact tag into the <head> of the site, on EVERY page and every
route — not just the homepage:

<script
  defer
  data-website-id="ts_a1b2c3d4e5f6"
  data-domain="example.com"
  src="https://truestat.io/js/t.js"
></script>

Requirements:
- It must be in the global layout / root document, so every route gets it.
- Do not modify the attributes. data-website-id and data-domain must stay
  exactly as written.
- Do not wrap it in a component that mounts and unmounts, and do not remove
  the script on unmount.
- Do not add any other analytics.

When you are done, tell me which file you put it in and confirm that it
applies to every route.

The last line matters. These builders will happily add the tag to one page and report success, and asking them to name the file and confirm the scope is what surfaces that.

If no events arrive

Paste this follow-up:

The TrueStat analytics script is not recording page views. Please:

1. Tell me what framework this project uses.
2. Show me the file where you added the script tag, and the exact lines.
3. Confirm whether that file is rendered for every route, or only for one page.
4. If the script was added inside a component's useEffect or lifecycle hook,
   move it into the root HTML document or root layout instead — a script that
   is added and removed on navigation does not track reliably.

Asking the builder to name its own framework is the useful part. These tools often do not tell you what they generated, and the fix differs between a Vite index.html, a Next.js layout and a plain React app.

The failure this catches

Across all four builders, the single most common outcome is the tag ending up on the homepage only. The prompt demands every route explicitly for that reason, and the install page's live connection state is what actually catches it: you will see your first event arrive, so the tag is clearly working — but your Top pages breakdown will only ever contain /.

If that is what you see, the tag is in a page component rather than the root layout. Re-run the follow-up prompt above.

The second failure

Some builders wrap the script in a React useEffect with a cleanup function that removes the script element on unmount. That tears the tracker down on navigation. The prompt tells the builder not to do this; if it did anyway, the follow-up prompt's step 4 is the fix.

Verify

Load the deployed site — not the builder's in-editor preview, which often runs on a different origin — and check the install page in the app. Then click through to a second route and confirm a second path appears in Top pages within a minute.

Ask for the crawler step too

The tag these builders add runs in a browser, so AI crawlers — which fetch your HTML without running JavaScript — stay invisible to it.

If your project has a server side (a Next.js app on Lovable or v0, an Express server on Replit), ask the builder for it in a second prompt:

Install the @truestat/ai-crawl package and report AI crawlers from the server, using site key YOUR_SITE_KEY.

See Server-side tracking for what the result should look like. A project that deploys as static files has nowhere to run this, and the browser tag is all it can have.

Was this page helpful?

Last updated September 14, 2026