Configuration

Every SDKConfig field, with its default and its unit.

The same SDKConfig object is accepted by init() in @pivolio/browser, by new Tracker(config), and by the config prop on PivolioProvider. Only writeKey and apiUrl are required.

1init({
2 writeKey: 'wk_live_xxxxxxxxxxxx',
3 apiUrl: 'https://api.pivolio.com',
4 autoPageView: true,
5 trackSPANavigation: true,
6});

Every option is init-time. Changing a value after the tracker exists has no effect. The two things you can change at runtime have methods: tracker.setConsent(...) and tracker.debug(...).

Required

writeKey
stringRequired

Your workspace’s write key, sent as the X-Write-Key header. Find it under Settings → API keys. Write keys can only ingest events — they can’t read data or change settings — so they’re safe to ship in browser code.

apiUrl
stringRequired

The collector base URL, e.g. https://api.pivolio.com. Point this at your own subdomain to beat ad-blockers and Safari ITP — see First-party domains.

Identity and storage

cookieDomain
string

Cookie domain, e.g. .example.com. Set this when you track across subdomains — without it, shop.example.com and www.example.com mint separate visitors. For separate registrable domains use the cross-domain linker instead.

cookiePath
stringDefaults to /

Cookie path.

storagePrefix
stringDefaults to __ut_

Prefix for every cookie and storage key the SDK writes. Change it only to avoid a collision with another script on the page; changing it on a live site orphans the existing identity and every visitor is counted as new.

secureCookies
booleanDefaults to true

Set the Secure flag, restricting cookies to HTTPS. Turn it off only for local development over plain HTTP.

anonymousIdTTL
numberDefaults to 365

Anonymous ID cookie lifetime, in days.

attributionTTL
numberDefaults to 30

How long captured UTMs and click IDs persist, in days. This is your client-side attribution window; the server applies per-platform click expiry on top of it, so raising this beyond 90 days buys little.

sessionTimeout
numberDefaults to 30

Inactivity before a new session starts, in minutes.

Behavior

autoPageView
booleanDefaults to false

Fire a page_view automatically when the tracker initializes. If you call page() yourself, leave this off or you’ll count every landing twice.

trackSPANavigation
booleanDefaults to false

Emit a page view on history.pushState/replaceState and popstate. Enable it for a single-page app that doesn’t reload between routes.

On Next.js, use <PivolioPageView /> instead — it’s App Router-aware, and combining the two double-counts navigations.

testMode
booleanDefaults to false

Stamp test_mode: true on every event. This excludes them from your billable usage and lets you filter them out of the events list.

It does not stop delivery and does not exclude them from reporting — test events still dispatch to connected destinations and still count in your dashboards. Use a separate workspace to isolate staging, not this flag.

debug
booleanDefaults to false

Verbose console logging. Toggle it at runtime with debug(true).

Privacy

respectDNT
booleanDefaults to false

When the browser sends Do Not Track, disable the tracker entirely — it never initializes, and isInitialized() returns false.

consent
Consent

Initial Google Consent Mode v2 state: { ad_storage, analytics_storage, ad_user_data, ad_personalization }, each 'granted' or 'denied'. Unset is treated as not-denied. See Identity and consent for what each category gates.

Transport

batching
booleanDefaults to true

Buffer events and send them via /batch. Turning this off sends each event immediately via /track — simpler to debug, materially more requests.

batchSize
numberDefaults to 10

Events buffered before an immediate flush.

flushInterval
numberDefaults to 2000

Maximum time to hold a partial batch, in milliseconds.

requestTimeout
numberDefaults to 10000

Per-request timeout, in milliseconds.

maxRetries
numberDefaults to 3

Total attempts before falling back to sendBeacon, with exponential backoff between them. 4xx responses other than 429 are permanent and stop retrying immediately — retrying a rejected payload only wastes the visitor’s battery.

Callbacks

onEventSent
(event: { eventId: string; eventName: string }) => void

Fires after an event is accepted by the collector.

onEventError
(error: Error, event: { eventId: string; eventName: string }) => void

Fires only after every delivery path has failed: retried fetch, then sendBeacon, then persisting to the offline queue. An event that lands in the offline queue is not lost — it is retried on the next page load — so this callback firing means the event is genuinely gone.

Next steps