Advanced tracking
Every option here is set as a data-* attribute on the loader tag. The defaults are tuned for most sites, so reach for these only when you need the specific behavior.
SPA route tracking
Section titled “SPA route tracking”data-spa is on by default. The tracker listens to History API navigations and hashchange and fires a pageview on each route change, so single-page apps are covered without extra code.
<script defer src="https://cdn.statskit.ai/v.js" data-site-id="vpk_live_…" data-spa="on"></script>For views that are not real navigations (modals, wizard steps), fire them yourself with statskit.page(path). Set data-spa="off" only if you want to take full manual control of pageviews.
Cookieless mode
Section titled “Cookieless mode”data-mode="cookieless" stores ids in sessionStorage only and rotates the visitor id roughly every 24 hours. It avoids persistent first-party storage, which is the usual trigger for a consent banner.
<script defer src="https://cdn.statskit.ai/v.js" data-site-id="vpk_live_…" data-mode="cookieless"></script>The default (persistent) mode keeps statskit_visitor_id as a stable UUID and statskit_session_id rolling after 30 minutes of inactivity. See identity for the full model.
First-party proxy
Section titled “First-party proxy”Route events through your own domain to resist ad-blockers and third-party-storage limits. Set data-proxy to a path prefix, then forward that path from your server to the StatsKit edge.
<script defer src="https://cdn.statskit.ai/v.js" data-site-id="vpk_live_…" data-proxy="/_v"></script>With data-proxy="/_v", the tracker posts events to /_v/e on your own origin. Your server forwards that request to https://edge.statskit.ai. Because the request is same-origin, ad-blockers that key on third-party domains do not see it.
Do-Not-Track and Global Privacy Control
Section titled “Do-Not-Track and Global Privacy Control”data-respect-dnt is off by default. Turn it on to make the tracker do nothing when the browser signals Do-Not-Track (DNT) or Global Privacy Control (GPC):
<script defer src="https://cdn.statskit.ai/v.js" data-site-id="vpk_live_…" data-respect-dnt="on"></script>When the signal is present, the tracker collects and sends nothing for that visitor.
Batching and delivery
Section titled “Batching and delivery”Events are buffered and flushed in batches rather than one request per event. Three attributes tune this:
| Attribute | Default | Effect |
|---|---|---|
data-flush | 5000 | Flush interval in milliseconds. |
data-batch | 20 | Flush as soon as this many events are buffered. |
data-max-buffer | 1000 | Hard cap on buffered events. On overflow the oldest are dropped. |
<script defer src="https://cdn.statskit.ai/v.js" data-site-id="vpk_live_…" data-flush="3000" data-batch="10" data-max-buffer="500"></script>The tracker also flushes on visibilitychange to hidden and on pagehide, using navigator.sendBeacon with a fetch(keepalive) fallback so events are not lost on unload. Failed batches retry with capped exponential backoff and honor 429 / Retry-After. Each event carries a UUID for server-side dedup, so a retried batch is not double-counted.