3 min read

Exclusions, Domains & Bot Filtering

Exclude your own visits, restrict ingestion to approved hostnames, skip specific links, and see how TrimStats drops bots before billing.

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

How does TrimStats filter bots, crawlers, and internal team traffic?

TrimStats drops automated bots, headless webdrivers, and known crawlers on the Fastify collector before ClickHouse writes or monthly billing counters increment. Site owners also enforce strict allowed-hostname lists per site key and exclude internal developer browsers via localStorage.setItem("trimstats_ignore", "1").

Exclude your own browser

Prevent your own team visits from skewing analytics by setting the trimstats_ignore flag in localStorage on your domain. Whenever this key holds any truthy value, t.js exits immediately before sending any beacons.

Browser DevTools Consolejs
1// Stop tracking this browser on the current domain
2localStorage.setItem('trimstats_ignore', '1');
3
4// Re-enable tracking later
5localStorage.removeItem('trimstats_ignore');

Add data-ts-ignore to any anchor tag whose clicks should not generate automatic outbound or download events.

HTML
<a href="https://status.acme.com" data-ts-ignore>System Status</a>

Allowed hostnames enforcement

Under Site settings -> General & Privacy -> Allowed hostnames, enter a comma-separated list of authorized domains (for example acme.dev, docs.acme.dev).

Site settings / General & Privacy
Populate Allowed hostnames so staging environments or copied snippets on unrelated domains are rejected with 403 Forbidden before touching your monthly event quota.
  • Subdomains are matched automatically: allowing acme.com permits acme.com, www.acme.com, and app.acme.com.
  • Requests whose page URL hostname is not on the allowlist are rejected with HTTP 403 Forbidden before touching Redis or counting against your monthly event quota.
  • This prevents accidental staging pollution or someone copying your public pk_live_... snippet onto an unrelated domain.

Automatic bot & crawler filtering

TrimStats filters non-human traffic at two layers so crawlers never inflate metrics or consume billable event quota:

LayerDetection signalBehavior
Browser (t.js)navigator.webdriver === trueExits immediately before sending any network request (covers Playwright, Puppeteer, Selenium, and headless CI runs).
Collector (/v1/collect)Empty or < 8 character User-Agent, plus regex covering search, social, uptime, SEO, HTTP clients, and AI crawlers (GPTBot, ClaudeBot, PerplexityBot, Googlebot, Bingbot, AhrefsBot, SemrushBot, HeadlessChrome, Lighthouse, curl/, wget/, python-requests, go-http-client, and more)Returns 202 Accepted immediately before Redis quota increment or human event writes; recognized AI crawlers are routed separately to crawler_events.

Common technical questions

Do filtered bots and search crawlers count against my TrimStats event quota?
No. Known crawlers, headless browsers, and automated probes are identified and dropped prior to billing counter updates so bot waves never consume your monthly plan allowance.
How do I stop my own staging or admin visits from skewing production stats?
Run localStorage.setItem("trimstats_ignore", "1") once in your browser console on your site domain, and restrict each site key to production hostnames under Site settings.

Related guides