Autocapture

Built-in browser event capture

Enable or disable

const analytics = createClient({
  publicKey: 'pk_live_xxx',
  autocapture: true, // default
})
const analytics = createClient({
  publicKey: 'pk_live_xxx',
  autocapture: {
    pageviews: true,
    pageleave: true,
    clicks: true,
    scrollDepth: true,
    forms: true,
    errors: true,
    webVitals: true,
    outboundLinks: true,
    fileDownloads: true,
    rageClicks: true,
  },
})

Built-in events

EventWhen it firesKey properties
$pageviewPage load and SPA navigation$pathname, $url, $referrer, $utm_*, $referrer_domain
$pageleaveTab hidden or page unload$duration_seconds, $scroll_depth
$clickClick on interactive elements$element_*, $click_x, $click_y
$outbound_clickClick on external links$href, $domain
$file_downloadClick on matching file links$file_extension, $file_name
$rage_clickRapid repeated clicks$click_count, $element_*
$scroll_depth25/50/75/100% milestones$depth_percent, $time_to_scroll_seconds
$form_startFirst focus in a form$form_id, $form_action, $field_name
$form_submitForm submit event$duration_seconds, $form_method
$form_abandonLeave page with active form$form_id, $duration_seconds
$errorwindow error / unhandled rejection$error_message, $error_stack
$web_vitalWeb Vitals observer events$metric_name, $metric_value, $metric_unit

Custom click metadata

Any clicked element attributes prefixed with data-analytics- are attached to $click as $data_* properties.

<button
  data-analytics-cta="hero"
  data-analytics-plan="pro"
>
  Start trial
</button>

Implementation note

Autocapture does not currently support an element-level opt-out attribute. If you need stricter control, disable clicks and track manually.

Next Steps