Integration docs
Three ways to integrate — pick one, done in minutes.
1 · Any site (recommended)
For any framework, add the line below to your <head> to automatically track pageviews (including SPA routes).
<script defer src="https://tutustat.com/t.js" data-site="ts_xxxxxxxx"></script> 2 · SvelteKit
Copy stat.ts into your project and call initStat during component initialization in the root +layout.svelte.
import { initStat } from '$lib/stat';
initStat({
site: 'ts_xxxxxxxx',
endpoint: 'https://tutustat.com'
}); Must be called synchronously during component initialization; calling it inside onMount throws “outside component initialisation”.
3 · Cross-platform users
Expose tutu_id_sub from your product’s /auth/me and provide getSub on the frontend — the same user is merged into one across all platforms.
initStat({
site: 'ts_xxxxxxxx',
endpoint: 'https://tutustat.com',
getSub: () => auth.user?.tutu_id_sub
}); 4 · Verify
Visit your site — “Live visitors” should increment, and you’ll see the visit in the overview within seconds.