Quickstart Installation
Add TrimStats to any website in under 60 seconds with a single deferred script under 2 KB gzipped.
How do you install TrimStats web analytics on a website?
Create a site in TrimStats to obtain your pk_live_ site key, paste one deferred 1.96 KB script tag inside your HTML <head>, and deploy. TrimStats tracks pageviews, SPA history navigation, outbound links, file downloads, and visibility-aware active dwell automatically with zero cookies or npm dependencies.
How TrimStats works
TrimStats loads a single, zero-dependency browser script (t.js) weighing 1.96 KB gzipped (enforced under a 3 KiB hard budget). When a visitor opens a page, the browser fetches t.js asynchronously via defer without blocking first paint, then dispatches a tiny navigator.sendBeacon JSON payload to our EU collector, which writes live counts to Valkey and analytical rows to ClickHouse.
Zero render blocking
Loaded with defer and transmitted via navigator.sendBeacon so Core Web Vitals stay untouched.
Cookie-less by default
No cookies or localStorage writes out of the box. Visitor hashes rotate every 24 hours on EU servers.
Works everywhere
Static HTML, Next.js, React, Astro, Vue, WordPress, Shopify, and Webflow all use the same tag.
Install in three steps
data-mode or data-friction whenever you enable those toggles below.- 1
Create your site in the dashboard
Open Add site, enter your display name and domain (for example
acme.com), choose your identity mode, and click Create site & get snippet to generate your uniquepk_live_...public key. - 2
Paste the script inside your HTML <head>
Place the tag inside the
<head>of every page you want to measure. Replacepk_live_your_keywith the public key from Site settings.index.htmlhtml1<head>2 <meta charset="utf-8" />3 <title>Acme</title>4 <script defer src="https://collect.trimstats.com/t.js" data-site="pk_live_your_key"></script>5</head> - 3
Verify live hits
Load your website in a browser tab (without an ad blocker or
trimstats_ignoreset), then click Verify installation in the setup flow or open your site Overview to confirm live visitors appear within seconds.
Build your custom snippet
Use the interactive configurator below to toggle optional features like first-party visitor IDs, UI friction tracking, or a reverse-proxied collector endpoint.
<script
defer
src="https://collect.trimstats.com/t.js"
data-site="pk_live_your_key"
></script>Enabling data-mode="first-party" in your HTML tag requires toggling First-party ID under Site settings as well. Without the server-side toggle, the collector ignores client visitor IDs and remains strictly cookie-less.
Where to go next
Framework & CMS guides
Copy-paste recipes for Next.js App Router, React/Vite, Astro, Nuxt, WordPress, Shopify, and Webflow.
Custom events & goals
Track signups, pricing clicks, and checkout steps with window.trimstats('event', ...).
Dual-mode identity
Compare cookie-less mode vs first-party IDs and learn when to call identify().
Revenue attribution webhooks
Connect Stripe, Paddle, Polar, or custom HMAC webhooks to measure revenue per channel.
Common technical questions
Does the TrimStats quickstart snippet require cookies or a consent banner?
How fast do live pageviews appear after pasting the TrimStats script?
Related guides
Recommended installation patterns for Next.js, React, Astro, Vue/Nuxt, WordPress, Shopify, Webflow, and Content Security Policy (CSP) headers.
Confirm events are reaching ClickHouse and diagnose common setup issues like 403 domain blocks, ad blockers, or missing data attributes.
Complete reference for every HTML data attribute supported by t.js, including first-party mode, UI friction, and custom proxy endpoints.