RTN Docs

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 },
});
OptionEventProperties
outboundLinksoutbound_link_clickedurl, destination_host, link_text
downloadsfile_downloadedurl, file_name, file_extension, link_text
formsform_submittedform_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). Pass downloads: { 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 },
  },
});
  • maxEvents per intervalMs window applies globally (ratePolicy) and per event name (eventRatePolicies).
  • sampleRate between 0 and 1 keeps that share of events.
  • Dropped events are reported to onDiagnostic as event_drop with reason sampled_out or rate_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');

On this page