Web SDK · v0.6.0
Automatic Tracking
Page views, opt-in interaction listeners, SPA page filtering, and client-side rate policies.
Page views
Page views are on by default. RTN records the initial load and SPA navigations through pushState, popstate, and hash routes such as #/cart. Plain anchors (#section) and query-only replaceState updates, such as filters and sorting, are not page views. The SDK waits 300 ms so your framework can update the title, and uses the previous page as the referrer.
Turn them off with autoPageViews: false and call rtn.page() yourself.
Filter and key SPA pages
rtn.init('WRITE_KEY', {
pageTracking: {
debounceMs: 300,
shouldTrackPage: (url) => !url.pathname.startsWith('/admin'),
key: (url) => url.pathname,
},
});key decides when two URLs count as the same page; a repeated key is dropped as duplicate_page.
Interaction listeners
Every interaction listener is opt-in:
rtn.init('WRITE_KEY', {
interactions: { outboundLinks: true, downloads: true, forms: true },
});| Option | Event | Properties |
|---|---|---|
outboundLinks | outbound_link_clicked | url, destination_host, link_text |
downloads | file_downloaded | url, file_name, file_extension, link_text |
forms | form_submitted | form_id, form_name, form_method, form_action |
- Outbound means a different origin from the current page.
- Downloads match common document, media, and archive extensions (
pdf,csv,xlsx,zip,mp4, and more). Passdownloads: { extensions: ['pdf', 'dwg'] }to set your own list. - Form tracking records metadata only. Field names and values are never collected, and the action URL is redacted.
You can also record these explicitly, for example from a custom button:
rtn.trackDownload('https://cdn.example.com/catalog-2026.pdf');
rtn.trackOutboundLink(document.querySelector('#partner-link'));Sampling and rate limits
Policies run in memory and never write tracking state before consent.
rtn.init('WRITE_KEY', {
ratePolicy: { maxEvents: 100, intervalMs: 60_000 },
eventRatePolicies: {
scroll_depth_reached: { maxEvents: 4, intervalMs: 60_000, sampleRate: 0.5 },
},
});maxEventsperintervalMswindow applies globally (ratePolicy) and per event name (eventRatePolicies).sampleRatebetween0and1keeps that share of events.- Dropped events are reported to
onDiagnosticasevent_dropwith reasonsampled_outorrate_limited.
Shared properties
Add properties to every following track and page event on the current page. Event properties win on conflict.
rtn.register({ storefront: 'outlet', ab_variant: 'checkout_b' });
rtn.unregister('ab_variant');