---
title: Autocapture in Browser SDK 2
description: "Configure automatic event tracking, engagement measurement, and page enrichment with Autocapture in Amplitude Browser SDK 2."
product: analytics
lang: en
last_updated: 2026-12-03
token_estimate: 9526
---
# Autocapture in Browser SDK 2

Autocapture is the set of plugins Browser SDK 2 installs during `init()` to track common browser events without code. You control them with the `autocapture` option, and your Amplitude project's remote configuration can override your settings per feature. For a general introduction, go to [Autocapture](https://amplitude.com/docs/data/autocapture).

> For AI agents: a documentation index is available at [/docs/llms.txt](/docs/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

## Choose a starting point

| `autocapture` value | Features on |
| --- | --- |
| Omitted | The default set: attribution, page views, sessions, form interactions, file downloads, and page URL enrichment. |
| `true` | The default set, plus element interactions, frustration interactions, network tracking, and web vitals. Performance tracking and experimental engaged time tracking stay off. |
| `false` | None. |
| An object | The default set, with your changes. Set a feature to `false` to turn it off, or to `true` or an options object to turn it on. |

```ts
amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: {
    elementInteractions: true,
    fileDownloads: false,
    pageViews: { trackHistoryChanges: "pathOnly" },
  },
});
```

In a Chrome extension, the SDK turns off the default set. Set each feature you want to `true`. This [default changed in 2.42.1](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2-release-notes#2421).

`autocapture` replaces the deprecated `defaultTracking` option. If you set both, `autocapture` wins.

## Features and events

| Feature | Option | Default | Events |
| --- | --- | --- | --- |
| [Marketing attribution](#marketing-attribution) | `attribution` | On | `$identify` with campaign user properties, campaign event properties, optional `[Amplitude] Attribution` |
| [Page views](#page-views) | `pageViews` | On | `[Amplitude] Page Viewed` |
| [Engaged time tracking](#engaged-time-tracking) | `engagedTimeTracking` | Off | Adds engaged and total time to matching page-view events. Experimental; requires 2.52.0 or later. |
| [Sessions](#sessions) | `sessions` | On | `session_start`, `session_end` |
| [Form interactions](#form-interactions) | `formInteractions` | On | `[Amplitude] Form Started`, `[Amplitude] Form Submitted` |
| [File downloads](#file-downloads) | `fileDownloads` | On | `[Amplitude] File Downloaded` |
| [Page URL enrichment](#page-url-enrichment) | `pageUrlEnrichment` | On | No event. Adds page properties to every event. |
| [Element interactions](#element-interactions) | `elementInteractions` | Off | `[Amplitude] Element Clicked`, `[Amplitude] Element Changed` |
| [Frustration interactions](#frustration-interactions) | `frustrationInteractions` | Off | `[Amplitude] Rage Click`, `[Amplitude] Dead Click`, `[Amplitude] Error Click`, `[Amplitude] Thrashed Cursor` |
| [Network tracking](#network-tracking) | `networkTracking` | Off | `[Amplitude] Network Request` |
| [Web vitals](#web-vitals) | `webVitals` | Off | `[Amplitude] Web Vitals` |
| [Performance tracking](#performance-tracking) | `performanceTracking` | Off | `[Amplitude] Main Thread Block` |

For every sub-option and default, go to [Autocapture options](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2/reference#autocapture-options) in the configuration reference.

## Remote configuration overrides local settings

By default, `init()` fetches your project's remote configuration from Amplitude before it installs plugins. You edit remote configuration in _Data > Settings > Autocapture_. For each feature that remote configuration sets, its value replaces yours. Features it doesn't set keep your local value. Remote configuration requires Browser SDK 2.10.0 or later, and its [default changed to on in 2.16.1](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2-release-notes#2161).

```ts
// Local configuration
amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: { pageViews: true, elementInteractions: true },
});

// Remote configuration: elementInteractions off, frustrationInteractions on
// Result: pageViews on, elementInteractions off, frustrationInteractions on
```

Remote configuration can turn on a feature even when you set `autocapture: false`. To make local settings final, turn off the fetch:

```ts
amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: false,
  remoteConfig: { fetchRemoteConfig: false },
});
```

The fetch goes to `https://sr-client-cfg.amplitude.com/config` (or `sr-client-cfg.eu.amplitude.com` for EU). The SDK caches the response in the browser and applies whichever arrives first, the cache or the network. If an ad blocker or a Content Security Policy blocks the request, the SDK uses the cached copy, or your local settings when no cache exists. To route it through your own server, set `remoteConfig.serverUrl` (Browser SDK 2.28.0 or later).

## Marketing attribution

Attribution reads UTM parameters, click IDs, and the referrer when the page loads. It records them in two independent ways, controlled by `attribution.trackingMethod`. Both run by default. The `eventProperty` method requires Browser SDK 2.40.0 or later, and the [default changed to both methods in 2.45.0](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2-release-notes#2450).

| Method | What it does | Use it for |
| --- | --- | --- |
| `userProperty` | Sends an `$identify` event that sets the campaign as user properties, and sets first-touch `initial_*` properties once. It sends the identify at the start of a session, or mid-session when the campaign changes. It stores the last campaign in an `AMP_MKTG_` cookie. The identify also unsets campaign fields that the new campaign doesn't have, such as UTM parameters, click IDs, and referrer fields. | First-touch and last-touch attribution on the user |
| `eventProperty` | Adds the current page's campaign parameters to the event properties of every event. It updates on page load and on SPA navigation. | Multi-touch attribution with [persisted properties](https://amplitude.com/docs/data/persisted-properties) |

The SDK reads these parameters: `utm_source`, `utm_medium`, `utm_campaign`, `utm_term`, `utm_content`, `utm_id`, `referrer`, `referring_domain`, `dclid`, `fbclid`, `gbraid`, `gclid`, `ko_click_id`, `li_fat_id`, `msclkid`, `rdt_cid`, `ttclid`, `twclid`, and `wbraid`.

```ts
amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: {
    attribution: {
      trackingMethod: "userProperty",
      excludeReferrers: [/example\.com$/, "checkout.partner.com"],
      resetSessionOnNewCampaign: true,
    },
  },
});
```

These options apply only to `userProperty` tracking:

- `excludeReferrers` ignores campaigns from matching referring domains. By default it excludes your own domain and its subdomains. Setting it replaces the default, so include your own domain.
- `excludeInternalReferrers` ignores referrers on the same domain as the page. Set `true` (or `{ condition: "always" }`) to always ignore them, or `{ condition: "ifEmptyCampaign" }` to ignore them only when the URL has no UTM parameters or click IDs. Requires Browser SDK 2.36.0 or later.
- `initialEmptyValue` is the value for `initial_*` properties that have no campaign value. The default is `"EMPTY"`.
- `resetSessionOnNewCampaign` starts a new session when the campaign changes.

`fallbackAttributionEvent` applies only to `eventProperty` tracking. Set it to `true` to send an `[Amplitude] Attribution` event on every page view, so campaign data arrives even if the user triggers no other event.

### Single-page apps lose campaign context

In a single-page app, `document.referrer` doesn't change after the first load, and routers often strip the query string. Two consequences:

- `userProperty` tracking reads the campaign only during `init()`. A campaign that appears later through `pushState` doesn't update user properties.
- `eventProperty` tracking replaces the campaign on each navigation. After a user moves from `/?utm_source=newsletter` to `/pricing`, later events have no `utm_source`, but they keep the original `referrer`.

Initialize the SDK before your router rewrites the URL, and keep campaign parameters on server-side redirects. To drop the referrer after the landing page, add an enrichment plugin:

```ts
const landingUrl = location.href;

amplitude.add({
  name: "drop-referrer-after-landing",
  execute: async (event) => {
    if (location.href !== landingUrl && event.event_properties) {
      delete event.event_properties.referrer;
      delete event.event_properties.referring_domain;
    }
    return event;
  },
});
```

## Page views

The SDK sends `[Amplitude] Page Viewed` when it initializes, and again when the URL changes through `history.pushState()`, the `popstate` event (back, forward, and hash changes), or, starting in version 2.49.0, `history.replaceState()`.

> **Warning:** Multi-step forms
>
> A multi-step form that updates in place without changing the URL produces one page view. To track each step, add a hash to the URL for each step, for example with [Google Tag Manager](https://support.google.com/tagmanager/answer/7679410?hl=en).

Each page view includes:

| Property | Value |
| --- | --- |
| `[Amplitude] Page Domain` | `location.hostname` |
| `[Amplitude] Page Location` | `location.href`, decoded |
| `[Amplitude] Page Path` | `location.pathname`, decoded |
| `[Amplitude] Page Title` | `document.title`, or `*****` when the `<title>` element has a `data-amp-mask` attribute |
| `[Amplitude] Page URL` | `location.href` without the query string |
| `[Amplitude] Page View ID` | A UUID for this page view, shared with element interaction events on the page |
| `[Amplitude] Page Counter` | The number of page views so far in this session |
| Campaign parameters | UTM parameters, click IDs, and referrer fields, when present |

Options:

- `trackOn` controls when to send page views. Omit it to send on every load and URL change. Set `"attribution"` to send a page view only when attribution sends a campaign. Set a function that returns `true` to send.
- `trackHistoryChanges` controls which URL changes count. The default sends a page view on any change to the URL, including the query string and hash. Set `"pathOnly"` to ignore changes that keep the same origin and path.
- `eventType` renames the event.

```ts
amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: {
    pageViews: {
      trackOn: () => location.pathname.startsWith("/app"),
      trackHistoryChanges: "pathOnly",
    },
  },
});
```

To add your own properties to page view events, use an enrichment plugin. For a working example, go to [page-view-tracking-enrichment](https://github.com/amplitude/Amplitude-TypeScript/blob/main/examples/plugins/page-view-tracking-enrichment/index.ts) on GitHub.

### Page titles in single-page apps

The SDK reads `document.title` right after `pushState()` returns. Routers in Angular, SvelteKit, React Router, and others often set the title after the URL changes, so the page view records the previous page's title. To fix this, turn off page views and track them from your router after it sets the title:

```ts
amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: { pageViews: false },
});

// Call from your router's navigation-end hook, after the title updates.
function trackPageView() {
  amplitude.track("[Amplitude] Page Viewed", {
    "[Amplitude] Page Domain": location.hostname,
    "[Amplitude] Page Location": location.href,
    "[Amplitude] Page Path": location.pathname,
    "[Amplitude] Page Title": document.title,
    "[Amplitude] Page URL": location.href.split("?")[0],
  });
}
```

Page views you track yourself don't include `[Amplitude] Page Counter` or `[Amplitude] Page View ID`.

## Engaged time tracking

Engaged time tracking measures how long a user actively interacts with a page while it has focus and remains visible. The Browser SDK adds cumulative engaged time and total elapsed time to matching page-view events, including custom event names. Use it to measure engagement with a single page, including visits without a second page view. Use [standard page-view tracking](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2/autocapture#page-views) when you only need to count page visits.

Engaged time tracking is an experimental feature in the stable SDK release. Its configuration and behavior can change. Contact your Amplitude account team before adopting it. The feature is free during the experimental period. Pricing for general availability isn't final.

### Enable engaged time tracking

Requires `@amplitude/analytics-browser` 2.52.0 or later.

Set `autocapture.engagedTimeTracking` to `true` during initialization. The SDK includes the engagement plugin; you don't need to install it separately.

```typescript
import * as amplitude from "@amplitude/analytics-browser";

amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: {
    pageViews: true,
    engagedTimeTracking: true,
  },
});
```

During the experimental period, engaged time tracking is off by default, and `autocapture: true` alone doesn't enable it. Explicitly set `autocapture.engagedTimeTracking` to `true` or an options object to enable it. Set `engagedTimeTracking` to `false` to keep it disabled.

The engagement plugin waits for a matching event before it starts measuring time. With `true` or `{}`, it matches `[Amplitude] Page Viewed`. Matching is exact and case-sensitive. Other event types follow normal delivery.

### Track a custom page-view event

If your application sends its own page views, disable automatic page views and set `pageViewEventType` to your event name:

```typescript
import * as amplitude from "@amplitude/analytics-browser";

amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: {
    pageViews: false,
    engagedTimeTracking: {
      pageViewEventType: "Article Viewed",
      secondaryPageViewEventType: "Engagement Resumed",
    },
  },
});

// Send a matching event for the initial page and each navigation.
amplitude.track("Article Viewed", { article_id: "123" });
```

Engagement doesn't create the initial event. With automatic page views disabled, focus, interaction, and navigation can't start measurement until your application sends a matching event. If you rename automatic events with `pageViews.eventType`, also set `engagedTimeTracking.pageViewEventType` to that name.

### How the SDK measures engagement

The SDK starts a rolling activity window when the engagement plugin processes a matching page-view event. Asynchronous enrichment can delay this start. The event keeps its original timestamp, but duration measurement starts when the plugin processes it, without backdating. Pointer presses, pointer movement, key presses, scrolling, touch starts, and wheel events refresh the window. Returning to the foreground also refreshes it.

With the default five-second window, an interaction credits up to five seconds of engaged time while the page stays visible and focused. Another interaction extends the window. Overlapping windows count once. After the window expires, time stops accumulating until another interaction. Hidden or unfocused pages don't accumulate engaged time.

For example, a user interacts three seconds after measurement starts on a focused page, then stops. The SDK counts up to eight seconds of engaged time. It doesn't count the overlapping windows twice. Passive reading without interaction stops contributing after the activity window expires.

The SDK sends cumulative snapshots every 15 seconds by default. A heartbeat sends the latest measurement; it doesn't count as user activity or extend the inactivity deadline.

### When a page view ends

A logical page view ends when the plugin processes the next matching page-view event, the user leaves the document, or the inactivity timeout expires. SDK reset, user or device identity changes, session ID changes, and plugin teardown also end the active view. Entering the browser's back/forward cache ends the view. Restoring the page can start a fresh view in the foreground if the plugin previously accepted a matching event at that URL.

The default inactivity timeout is three minutes after the last activity. Returning before that deadline resumes the same view. Activity after the deadline starts a new logical view at the same URL. By default, the new event uses `pageViewEventType`, which can increase page-view counts. Set `secondaryPageViewEventType` to a different name, such as `"Engagement Resumed"`, to distinguish these views from primary page views.

The SDK uses the secondary name for activity-based renewal after inactivity, identity or session changes, reset, and back/forward cache restoration. Each renewed view has a fresh timestamp and insert ID. Renewal doesn't copy the previous event's application properties, such as `article_id` or campaign fields. Normal SDK enrichment can add its own fields. Include both event names when reporting engagement across primary and renewed views. If the secondary name differs from the primary name, manually tracking the secondary name doesn't start engagement.

The timeout isn't a three-minute limit on total time. If the last activity occurs 20 seconds after a page view starts, the SDK finalizes it at three minutes and 20 seconds, unless another boundary ends it sooner.

For automatic page views in single-page applications, `pageViews.trackHistoryChanges` controls which URL changes send a matching event. Set it to `"pathOnly"` to track origin or path changes instead of query-string or hash changes.

For custom page views, send a matching event on each navigation. URL or history changes alone don't end the current engagement view or start another. After a URL change, automatic renewal waits for a matching page-view event at the new URL.

### Configure timing

Pass an options object instead of `true` to customize timing. All durations use milliseconds.

```typescript
import * as amplitude from "@amplitude/analytics-browser";

amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: {
    pageViews: {
      trackHistoryChanges: "pathOnly",
    },
    engagedTimeTracking: {
      secondaryPageViewEventType: "Engagement Resumed",
      activityWindowMillis: 5000,
      heartbeatIntervalMillis: 15000,
      inactivityTimeoutMillis: 180000,
    },
  },
});
```

For every option, type, default, and validation constraint, go to [EngagedTimeOptions](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2/reference#engagedtimeoptions).

### Engagement event properties

Engaged time tracking enriches each matching page-view event. Heartbeats update the same logical view instead of creating another analytics event. Each snapshot retains the event name, original timestamp, insert ID, identity, and session. Snapshots also retain application properties from the start of the view.

In normal initialization, the SDK captures page context after page-view and URL enrichment. Heartbeats preserve those page fields and don't increment the page counter. A renewed view passes through normal enrichment as a new event. Custom events don't gain a page counter if the page-view source is disabled or uses another name.

| Property | Type and unit | Meaning |
| --- | --- | --- |
| `[Amplitude] Engaged Time` | Number, milliseconds | Cumulative time within activity windows while the page is visible and focused. Excludes idle gaps and background time. |
| `[Amplitude] Total Time` | Number, milliseconds | Elapsed time from the start of the logical page view to its latest snapshot or finalization. Includes idle and background time within that view, capped at its inactivity deadline. |

Divide either property by `1000` to express it in seconds. For average engaged time per view, average `[Amplitude] Engaged Time` over events that contain the property. If you configure a secondary event name, choose whether your report includes primary views, renewed views, or both. Standard page views without engaged time tracking don't contain this measurement, so don't treat a missing property as zero.

Snapshots contain cumulative values for one logical page view. Don't sum successive snapshots from the same view. `[Amplitude] Snapshot Version` and `[Amplitude] Engagement Snapshot Reason` are internal diagnostic properties, rather than stable reporting dimensions.

### Compare with built-in time spent metrics

The SDK's duration properties and Amplitude's built-in [Time Spent metrics](https://amplitude.com/docs/analytics/charts/data-tables/time-spent-analysis) measure different things. Built-in metrics calculate time from event timestamps at query time. They don't use `[Amplitude] Engaged Time` or `[Amplitude] Total Time`.

| Measurement | How it calculates time | Idle and background time | Single-page visits and final page views |
| --- | --- | --- | --- |
| SDK `[Amplitude] Engaged Time` | Accumulates activity windows for each logical page view in the browser. | Excludes time outside an activity window and time when the page is hidden or unfocused. | Can measure engagement without a subsequent page view, subject to snapshot delivery. |
| SDK `[Amplitude] Total Time` | Measures elapsed time from the start of a logical page view to its latest snapshot or finalization. | Includes idle and background time within the view, up to its inactivity deadline. The default deadline is three minutes after the last activity. | Can measure elapsed time without a subsequent page view, subject to snapshot delivery. |
| Built-in Time Spent metrics | Calculate the duration between consecutive matching events. Gaps over 30 minutes don't contribute time. | Don't directly observe browser focus or interaction. Idle and background time can contribute when it falls between matching events within the timeout. | Don't attribute time to a lone matching event or the final matching event because neither has a subsequent matching event. |

For the same SDK page view, engaged time can't exceed total time. Neither SDK property has a fixed higher-or-lower relationship with the built-in metric:

- **Built-in time can be higher**: A user opens a focused page, stops interacting, and triggers the next matching page-view event ten minutes later. The built-in metric can attribute the ten-minute gap to the first page. With default settings, the SDK credits up to five seconds of engaged time and finalizes the first view after three minutes without activity.
- **SDK time can be higher**: A user interacts with a single page for 20 seconds and then leaves. The SDK can record positive engaged and total time through its snapshots. With only one matching page-view event, the built-in metric attributes no time. Gaps over the built-in metric's 30-minute timeout can also cause it to report less time than the SDK.

Grouping and averaging can introduce further differences. Built-in Time Spent attributes an interval to the group-by property value on its starting event. Its per-user, per-page, and per-session averages use users, time-spent windows, or sessions with non-zero time spent. An average of the SDK property over measured page views can include views with zero engaged time. An SDK inactivity timeout can also split one visit into multiple logical page views.

When comparing charts, align the selected events, filters, group-by properties, date range, units, and averaging denominator. Account for delayed ingestion before comparing recent data. These measurement rules explain why the values needn't match; they don't establish the cause of a particular discrepancy.

### Engagement delivery and limitations

Page views with engaged time tracking use delayed ingestion so the final event can include accumulated time. Don't expect the page-view event to appear immediately after page load or after each heartbeat.

The SDK sends a final snapshot at the end of the view. If it can't deliver that snapshot, the service falls back to the last accepted snapshot after expiration. Processing is asynchronous and best effort, with no guaranteed ingestion latency. The recorded durations don't include the wait for service expiration or ingestion. A missing final snapshot can omit engagement since the last accepted snapshot.

- **User properties**: Engaged page views omit `user_properties` to prevent delayed events from overwriting newer updates. Send user-property changes through a separate [Identify call](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2/track-events#set-user-properties).
- **Consent**: Calling `setOptOut(true)` discards the active engagement state and stops its heartbeats.
- **Network access**: By default, delayed events use a dedicated regional endpoint, selected by `serverZone`: `https://delayed-events.prod.us-west-2.amplitude.com/2/httpapi/delayed` for US projects or `https://delayed-events.prod.eu-central-1.amplitude.com/2/httpapi/delayed` for EU projects. With a custom `serverUrl`, the SDK appends `/delayed` to that URL. Setting `delayedEventsServerUrl` overrides both defaults and the custom `serverUrl`. If you use a proxy or network allowlist, permit requests to the endpoint that applies to your configuration.
- **Custom enrichment**: Plugins registered after engagement run again on every snapshot. Their returned properties don't automatically update the saved source event, so their values can change between snapshots. Avoid mutating nested application properties after tracking.
- **Invalid or oversized events**: If the SDK can't serialize or queue a snapshot, it sends the original event normally without engaged time tracking.
- **Browser lifecycle**: Browser suspension, network failures, and page exit can prevent final delivery. Use the measurements as best-effort engagement data.

### Verify engaged time tracking

1. Open a test page in a visible, focused browser tab. Confirm the SDK or your application sends the configured `pageViewEventType`, then interact for more than 15 seconds.
2. Check the browser's network panel for periodic requests to the delayed-event endpoint.
3. Switch tabs. Engaged time should stop increasing while the test page is in the background.
4. Return and interact before the inactivity timeout to continue the same view. Repeat after the timeout and confirm the renewed view uses `secondaryPageViewEventType`, or the primary event name if you omit the secondary name.
5. Navigate away and allow time for ingestion. Inspect the page-view event for `[Amplitude] Engaged Time` and `[Amplitude] Total Time`, both in milliseconds.

## Sessions

The SDK sends `session_start` when a session begins and `session_end` for the previous session when the next one begins. Amplitude displays them as `[Amplitude] Start Session` and `[Amplitude] End Session`. With `sessions: false`, the SDK still assigns session IDs to events. For session rules, go to [Identity and sessions](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2/identity-and-sessions#how-sessions-work).

## Form interactions

The SDK tracks `<form>` elements:

- `[Amplitude] Form Started` on the first change to any field in the form.
- `[Amplitude] Form Submitted` on submit. If the user submits without changing a field, the SDK sends `Form Started` first.

Both events include `[Amplitude] Form ID`, `[Amplitude] Form Name`, and `[Amplitude] Form Destination` (the form's `action` URL).

Forms with the `novalidate` attribute fire `submit` even when the input is invalid. To decide which submits count, pass `shouldTrackSubmit` (Browser SDK 2.34.0 or later):

```ts
amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: {
    formInteractions: {
      shouldTrackSubmit: (event) =>
        (event.target as HTMLFormElement).checkValidity(),
    },
  },
});
```

## File downloads

The SDK sends `[Amplitude] File Downloaded` when a user clicks an `<a>` element whose URL path ends in one of these extensions: `pdf`, `xls`, `xlsx`, `doc`, `docx`, `txt`, `rtf`, `csv`, `exe`, `key`, `pps`, `ppt`, `pptx`, `7z`, `pkg`, `rar`, `gz`, `zip`, `avi`, `mov`, `mp4`, `mpg`, `mpeg`, `wmv`, `mid`, `midi`, `mp3`, `wav`, or `wma`. It watches links added after load too.

Properties: `[Amplitude] File Extension`, `[Amplitude] File Name` (the URL path), `[Amplitude] Link ID`, `[Amplitude] Link Text`, and `[Amplitude] Link URL`.

## Page URL enrichment

Page URL enrichment adds page context to every event, including custom ones: `[Amplitude] Page Domain`, `[Amplitude] Page Location`, `[Amplitude] Page Path`, `[Amplitude] Page Title`, `[Amplitude] Page URL`, `[Amplitude] Previous Page Location`, and `[Amplitude] Previous Page Type`. It doesn't overwrite a property the event already has. For details, go to [Page URL enrichment plugin](https://amplitude.com/docs/sdks/analytics/browser/page-url-enrichment-plugin). Requires Browser SDK 2.22.0 or later, and the [default changed to on in 2.29.0](https://amplitude.com/docs/sdks/analytics/browser/browser-sdk-2-release-notes#2290).

If you turn off Autocapture, you can still add the plugin yourself:

```ts
import { pageUrlEnrichmentPlugin } from "@amplitude/plugin-page-url-enrichment-browser";

amplitude.add(pageUrlEnrichmentPlugin());
amplitude.init("AMPLITUDE_API_KEY", { autocapture: false });
```

## Element interactions

Element interactions send `[Amplitude] Element Clicked` and `[Amplitude] Element Changed` for interactive elements. [Visual labeling](https://amplitude.com/docs/data/visual-labeling) and [Zoning Insights](https://amplitude.com/docs/zoning-insights) depend on these events. For the data collected and how text masking works, go to [Autocapture privacy and security](https://amplitude.com/docs/data/autocapture#privacy-and-security).

By default the SDK tracks clicks and changes on `a`, `button`, `input`, `select`, `textarea`, `label`, `video`, `audio`, `[contenteditable="true"]`, `[data-amp-default-track]`, and `.amp-default-track`. It also tracks clicks on `div`, `span`, and `h1` through `h6` when the click changes the DOM or navigates.

```ts
import * as amplitude from "@amplitude/analytics-browser";

amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: {
    elementInteractions: {
      cssSelectorAllowlist: [
        ...amplitude.Types.DEFAULT_CSS_SELECTOR_ALLOWLIST,
        ".track-me",
      ],
      pageUrlExcludelist: [/\/admin\//],
      dataAttributePrefix: "data-analytics-",
    },
  },
});
```

- `cssSelectorAllowlist` replaces the default list. Spread `DEFAULT_CSS_SELECTOR_ALLOWLIST` to extend it. Import it as `amplitude.Types.DEFAULT_CSS_SELECTOR_ALLOWLIST` from `@amplitude/analytics-browser`; `@amplitude/plugin-autocapture-browser` doesn't export it.
- `actionClickAllowlist` replaces the `div`, `span`, and heading list for clicks that change the page. Set `[]` when you narrow `cssSelectorAllowlist`, so only your selectors count.
- `pageUrlAllowlist` and `pageUrlExcludelist` limit tracking by page URL. The exclude list wins.
- `shouldTrackEventResolver` decides per element. When you set it, the SDK ignores the allowlists.
- `dataAttributePrefix` captures matching `data-` attributes as properties. The default is `data-amp-track-`, so `data-amp-track-plan="pro"` becomes the `plan` property.
- `maskTextRegex` masks text that matches your patterns, in addition to the SDK's built-in masking.
- `shadowDomEnabled` (experimental) captures interactions inside open shadow roots, up to `maxShadowDomDepth` boundaries (default `1`, maximum `10`). After it turns on, it stays on until the next full page load.

Event properties include `[Amplitude] Element ID`, `[Amplitude] Element Class`, `[Amplitude] Element Tag`, `[Amplitude] Element Text` (clicks only), `[Amplitude] Element Href` (clicks only), `[Amplitude] Element Position Left`, `[Amplitude] Element Position Top`, `[Amplitude] Element Hierarchy`, `[Amplitude] Element Path` (a CSS selector for the element), `[Amplitude] Element Attributes`, `[Amplitude] Element Aria Label`, `[Amplitude] Element Parent Label`, `[Amplitude] Viewport Height`, `[Amplitude] Viewport Width`, `[Amplitude] Page URL`, and `[Amplitude] Page Title`.

## Frustration interactions

`frustrationInteractions: true` turns on rage clicks and dead clicks. Error clicks and thrashed cursor are off until you turn them on individually. Frustration interactions require Browser SDK 2.24.0 or later.

| Signal | Event | Definition |
| --- | --- | --- |
| Rage click | `[Amplitude] Rage Click` | Four or more clicks on the same element, within 50 pixels, in one second. Tracked on any element. |
| Dead click | `[Amplitude] Dead Click` | A click on an interactive element that changes neither the DOM nor the URL within three seconds. |
| Error click | `[Amplitude] Error Click` | A click on an interactive element followed within two seconds by a JavaScript error, console error, or unhandled promise rejection. Properties include `[Amplitude] Kind`, `[Amplitude] Message`, `[Amplitude] Stack`, `[Amplitude] Filename`, `[Amplitude] Line Number`, `[Amplitude] Column Number`, and the clicked element's properties, such as `[Amplitude] Element Text`. |
| Thrashed cursor | `[Amplitude] Thrashed Cursor` | Rapid back-and-forth pointer movement: 20 direction changes (minimum 5) within 2,000 ms (maximum 4,000). The SDK counts X-axis and Y-axis direction changes separately. |

```ts
amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: {
    frustrationInteractions: {
      rageClicks: true,
      deadClicks: { cssSelectorAllowlist: ["button", "a"] },
      errorClicks: true,
      thrashedCursor: { directionChanges: 12, threshold: 1500 },
    },
  },
});
```

Dead clicks and error clicks use the interactive-element lists `DEFAULT_DEAD_CLICK_ALLOWLIST` and `DEFAULT_ERROR_CLICK_ALLOWLIST` unless you set `cssSelectorAllowlist`. For the selectors, go to [frustration-interactions.ts](https://github.com/amplitude/Amplitude-TypeScript/blob/main/packages/analytics-core/src/types/frustration-interactions.ts) on GitHub.

Each signal also accepts `pageUrlAllowlist`, `pageUrlExcludelist`, `shouldTrackEventResolver`, `dataAttributePrefix`, and `maskTextRegex` at the `frustrationInteractions` level.

## Network tracking

Network tracking sends `[Amplitude] Network Request` for `fetch` and `XMLHttpRequest` calls. By default it captures only responses with status `500` through `599`, and it ignores requests to Amplitude. Requires Browser SDK 2.17.0 or later.

```ts
amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: {
    networkTracking: {
      ignoreHosts: ["*.example-cdn.com"],
      captureRules: [
        { statusCodeRange: "400-599" },
        {
          urls: [/https:\/\/api\.example\.com\/orders/],
          methods: ["POST"],
          statusCodeRange: "0,200-599",
          responseHeaders: true,
          responseBody: { allowlist: ["order/id", "order/status"] },
        },
      ],
    },
  },
});
```

The SDK checks `captureRules` from last to first and applies the first rule that matches the URL, so put specific rules after general ones. Each rule accepts:

- `urls` (string or RegExp, supports `*`) or the older `hosts`. Omit both to match every URL.
- `methods`, for example `["POST", "PUT"]`. Default: all.
- `statusCodeRange`, a comma-separated list of codes and ranges. Default: `"500-599"`. `0` matches requests that failed without a response.
- `requestHeaders` and `responseHeaders`: `true` captures a fixed set of non-sensitive headers, such as `content-type` and `cache-control`. An array captures exactly the names you list.
- `requestBody` and `responseBody`: JSON bodies only. `allowlist` lists JSON pointers to keep (`*` matches one key, `**` any depth). `excludelist` removes keys the allowlist matched. The SDK captures no body content unless you set an allowlist.

For example, with this body:

```json
{ "a": "A", "b": { "c": "C", "d": { "e": "E", "f": "F" } }, "g": "G" }
```

| `allowlist` | `excludelist` | Captured |
| --- | --- | --- |
| `["a"]` | None | `{ "a": "A" }` |
| `["*"]` | None | `{ "a": "A", "g": "G" }` |
| `["b/c"]` | None | `{ "b": { "c": "C" } }` |
| `["b/d/*"]` | None | `{ "b": { "d": { "e": "E", "f": "F" } } }` |
| `["b/**"]` | None | `{ "b": { "c": "C", "d": { "e": "E", "f": "F" } } }` |
| `["**/e"]` | None | `{ "b": { "d": { "e": "E" } } }` |
| `["b/**"]` | `["b/d/f"]` | `{ "b": { "c": "C", "d": { "e": "E" } } }` |

Event properties: `[Amplitude] URL` (with sensitive parts masked), `[Amplitude] URL Query`, `[Amplitude] URL Fragment`, `[Amplitude] Request Method`, `[Amplitude] Status Code`, `[Amplitude] Error Code`, `[Amplitude] Error Message`, `[Amplitude] Start Time`, `[Amplitude] Completion Time`, `[Amplitude] Duration`, `[Amplitude] Request Body Size`, `[Amplitude] Response Body Size`, and, when configured, `[Amplitude] Request Body`, `[Amplitude] Response Body`, `[Amplitude] Request Headers`, and `[Amplitude] Response Headers`.

## Web vitals

Web vitals sends one `[Amplitude] Web Vitals` event per page load, when the tab first becomes hidden. It includes `[Amplitude] LCP`, `[Amplitude] FCP`, `[Amplitude] INP`, `[Amplitude] CLS`, and `[Amplitude] TTFB` when the browser reports them, plus the page domain, location, path, title, and URL. For metric definitions, go to web.dev: [LCP](https://web.dev/articles/lcp), [FCP](https://web.dev/articles/fcp), [INP](https://web.dev/articles/inp), [CLS](https://web.dev/articles/cls), and [TTFB](https://web.dev/articles/ttfb). Requires Browser SDK 2.20.0 or later.

In single-page apps, set `webVitals: { reportSoftNav: true }` (experimental) to also send one event per soft navigation. This requires the Soft Navigations API (Chromium 151 and later). Other browsers report only the initial load.

## Performance tracking

Performance tracking sends `[Amplitude] Main Thread Block` when the main thread stays busy for at least 100 ms. It uses the Long Animation Frames API where available and falls back to Long Tasks. `autocapture: true` doesn't turn it on. Requires Browser SDK 2.41.0 or later.

```ts
amplitude.init("AMPLITUDE_API_KEY", {
  autocapture: {
    performanceTracking: {
      mainThreadBlock: { durationThreshold: 200 },
    },
  },
});
```

