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
| Event | When it fires | Key properties |
|---|---|---|
$pageview | Page load and SPA navigation | $pathname, $url, $referrer, $utm_*, $referrer_domain |
$pageleave | Tab hidden or page unload | $duration_seconds, $scroll_depth |
$click | Click on interactive elements | $element_*, $click_x, $click_y |
$outbound_click | Click on external links | $href, $domain |
$file_download | Click on matching file links | $file_extension, $file_name |
$rage_click | Rapid repeated clicks | $click_count, $element_* |
$scroll_depth | 25/50/75/100% milestones | $depth_percent, $time_to_scroll_seconds |
$form_start | First focus in a form | $form_id, $form_action, $field_name |
$form_submit | Form submit event | $duration_seconds, $form_method |
$form_abandon | Leave page with active form | $form_id, $duration_seconds |
$error | window error / unhandled rejection | $error_message, $error_stack |
$web_vital | Web 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.