Start here4 min read

Quickstart Installation

Add TrimStats to any website in under 60 seconds with a single deferred script under 2 KB gzipped.

Imtiaz Rayhan
Imtiaz RayhanCo-Founder & Lead Engineer, DotCamp & TrimStats
Verified against live TrimStats APIs
Quick reference

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

Site settings / Tracking snippet
Every site gets a pre-filled tracking snippet under Site settings. The tag automatically adds data-mode or data-friction whenever you enable those toggles below.
  1. 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 unique pk_live_... public key.

  2. 2

    Paste the script inside your HTML <head>

    Place the tag inside the <head> of every page you want to measure. Replace pk_live_your_key with the public key from Site settings.

    index.htmlhtml
    1<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. 3

    Verify live hits

    Load your website in a browser tab (without an ad blocker or trimstats_ignore set), then click Verify installation in the setup flow or open your site Overview to confirm live visitors appear within seconds.

Site analytics / Overview
As soon as your first beacon arrives, the live badge updates in real time and Overview begins populating KPIs, daily trends, top pages, and referrers.

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.

Interactive Snippet Builder
Customize your tracker attributes and copy a production-ready tag.
Cookie-less · No banner
<script
  defer
  src="https://collect.trimstats.com/t.js"
  data-site="pk_live_your_key"
></script>
Remember to enable matching toggles under Site settings so the collector accepts first-party IDs.
Keep dashboard settings in sync

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

Common technical questions

Does the TrimStats quickstart snippet require cookies or a consent banner?
No. By default, t.js runs strictly cookie-less with zero browser cookies and zero localStorage writes, hashing visits transiently on EU servers in Germany with a 24-hour rotating SHA-256 salt.
How fast do live pageviews appear after pasting the TrimStats script?
After deploying the deferred script, open your site and check for a 202 POST request to collect.trimstats.com in browser DevTools. Live visitors update in the dashboard within seconds across a 300-second active window.

Related guides