5 min read

Verify & Troubleshoot

Confirm events are reaching ClickHouse and diagnose common setup issues like 403 domain blocks, ad blockers, or missing data attributes.

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

How do you verify that TrimStats is collecting events and diagnose missing traffic?

Open Chrome DevTools Network tab, reload your site, and confirm t.js returns HTTP 200 and POST /v1/collect returns HTTP 202 Accepted. If hits are missing, verify your site domain allowlist, check for localStorage trimstats_ignore=1, confirm data-site matches your key, and inspect CSP console errors.

How analytics beacons behave in the browser

When debugging analytics in browser DevTools, two behaviors often surprise first-time users: requests return HTTP `202 Accepted` (meaning the collector queued the beacon asynchronously without stalling the browser, rather than waiting on a synchronous database commit), and navigator.sendBeacon shows up under the Fetch/XHR or Ping filter with Content-Type: text/plain to avoid extra CORS preflight requests.

Site analytics / Overview (live verification)
Once POST /v1/collect returns 202 Accepted, the live badge at the top of Overview increments within seconds from Valkey/Redis.

Verify in browser DevTools

  1. 1

    Open the Network tab

    Open Chrome or Firefox DevTools, switch to the Network tab, enable Preserve log, and filter by collect or t.js.

  2. 2

    Reload the page

    Confirm t.js returns HTTP 200 and a subsequent POST request to https://collect.trimstats.com/v1/collect returns HTTP 202 Accepted.

  3. 3

    Inspect the beacon payload

    Click the /v1/collect request and open the Payload tab. You should see a compact JSON body containing s (your pk_live_... key), t: "pageview", and u (the current URL).

  4. 4

    Check the dashboard

    Open your site Overview or click Verify installation in onboarding. Live visitor counts update in real time from Redis, and ClickHouse event rows appear within a few seconds.

Diagnosing collector HTTP responses

StatusResponse / CauseHow to fix
202 AcceptedEvent queued for ingestion (or silently dropped because the User-Agent matched a bot).Normal for real browsers. If testing via curl or headless automation, note that bots and navigator.webdriver sessions are intentionally filtered.
400 Bad RequestInvalid beacon payloadCheck custom event payloads or manual API calls against the Collector Beacon API schema.
403 ForbiddenOrigin domain not allowedThe page hostname is not in your site Allowed hostnames list. Add the domain (or staging hostname) under Site settings -> General & Privacy.
404 Not FoundUnknown site keyYour data-site value does not match an active site. Copy the exact pk_live_... key from Site settings.
429 Too Many RequestsMonthly event quota exceededYour organization exceeded 120% of its monthly plan limit (including the 20% soft grace buffer). Upgrade your plan under Billing & account.
Site settings / General & Privacy
If DevTools shows 403 Forbidden on /v1/collect, verify that your live or staging domain appears inside Allowed hostnames under Site settings.

Common issues checklist

  • No `/v1/collect` request at all: Check whether you previously ran localStorage.setItem('trimstats_ignore', '1') in that browser, or whether a browser extension blocked the request.
  • Automated browser tests see zero beacons: TrimStats intentionally exits immediately when navigator.webdriver is true (Playwright, Puppeteer, Selenium, Cypress) to keep synthetic test runs out of production analytics.
  • Script optimizers stripping `data-site`: Some WordPress or CDN script-combining plugins merge external scripts and drop data-* attributes. Exclude t.js from script concatenation and minification.
  • Staging or `localhost` traffic blocked: When Allowed hostnames is populated in Site settings, requests from unlisted hostnames receive 403. Either leave Allowed hostnames empty during local development or create a separate staging site.
  • First-party cohorts remain empty: Confirm both data-mode="first-party" is present on your <script> tag AND First-party ID is saved under Site settings.

Common technical questions

Why does /v1/collect return HTTP 202 Accepted even when a hit is filtered?
TrimStats returns 202 quickly after validating site keys and dropping automated bots, localhost previews, or disallowed hostnames so ingestion stays non-blocking and never exposes internal filter logic to scrapers.
Why do I see zero hits when testing on localhost or Vercel preview URLs?
TrimStats enforces your configured domain allowlist and ignores automated webdriver sessions or browsers where trimstats_ignore is set. Add your staging hostname or test from your production domain to confirm delivery.

Related guides