Web SDK · v0.6.0
Configuration
Every option accepted by rtn.init and createClient, with defaults.
Pass options as the second argument to rtn.init:
rtn.init('WRITE_KEY', {
consent: 'pending',
currency: 'USD',
cookieDomain: '.example.com',
debug: true,
});With a bundler, pass the same options to createClient together with writeKey and endpoint.
Options
| Option | Default | Description |
|---|---|---|
endpoint | Script origin | Ingest base URL without /v1/batch. Required with createClient. |
consent | Stored decision, otherwise 'granted' | Initial analytics decision. See Consent. |
autoPageViews | true | Tracks the initial page and SPA navigations (pushState, popstate, hash routes). |
interactions | All off | Opt-in listeners for outbound links, downloads, and forms. See Automatic Tracking. |
pageTracking | — | SPA page filter, custom page key, and debounce: shouldTrackPage, key, debounceMs. |
ratePolicy | — | Global in-memory sampling and rate limit. |
eventRatePolicies | — | Per-event policies applied in addition to ratePolicy. |
currency | 'TRY' | ISO 4217 currency used by ecommerce helpers when an event has none. |
cookieDomain | Current host | Shares the anonymous and user ID across subdomains, for example .example.com. |
batchSize | 10 | Events per batch. |
flushIntervalMs | 5000 | Maximum wait before a batch is sent. |
debug | false | Logs events, warnings, and server rejection reasons to the console. |
ignoredReferrers | — | Extra referrer hosts that must not start a new visit, such as your payment provider. Common payment and 3-D Secure hosts are built in. |
redactParams | — | Extra URL parameters whose values become redacted. |
redactPropertyKeys | — | Extra property keys whose values become redacted before queueing. |
beforeSend | — | (event) => event | null. Change or drop an event before it is queued. |
onDiagnostic | — | Receives queue drops, storage errors, and quality-policy drops. |
See Privacy Controls for the redaction options and beforeSend.
Diagnostics
onDiagnostic receives one of these objects. A throwing callback never stops the SDK.
| Diagnostic | Meaning |
|---|---|
{ type: 'queue_drop', reason: 'max_count' | 'max_bytes' | 'expired', count } | The offline queue exceeded 1,000 events or 512 KiB, or events were older than 7 days. |
{ type: 'persistence_error' } | localStorage could not be written. |
{ type: 'event_drop', reason: 'sampled_out' | 'rate_limited' | 'duplicate_page', event } | A quality policy dropped the event. |
rtn.init('WRITE_KEY', {
onDiagnostic: (diagnostic) => console.debug('[rtn diagnostic]', diagnostic),
});