# @amplitude/plugin-autocapture-browser

Latest version **1.29.5** (published 2026-09-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install @amplitude/plugin-autocapture-browser
pnpm add @amplitude/plugin-autocapture-browser
yarn add @amplitude/plugin-autocapture-browser
bun add @amplitude/plugin-autocapture-browser
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.29.5 |
| Published | 2026-09-29 |
| First published | 2024-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 1.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 179 |
| Author | Amplitude Inc |
| Maintainers | curtisbliu, kelson.warner, sdk.dev, eric_amplitude, daniel-graham-amplitude, jjwang123 |

## Links

- npm: https://www.npmjs.com/package/@amplitude/plugin-autocapture-browser
- Repository: https://github.com/amplitude/Amplitude-TypeScript
- Issues: https://github.com/amplitude/Amplitude-TypeScript/issues
- npm.io page: https://npm.io/package/@amplitude/plugin-autocapture-browser

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.4.1
- [@amplitude/analytics-core](https://npm.io/package/@amplitude/analytics-core.md) 2.59.0
- [@amplitude/element-selector](https://npm.io/package/@amplitude/element-selector.md) 0.3.1

## Recent versions

- 1.29.5 (latest) — 2026-09-29
- 1.29.3-video-analytics-5.0 (video-analytics-5) — 2026-09-22
- 1.29.2-video-analytics-4.0 (video-analytics-4) — 2026-09-17
- 1.29.1-video-analytics-2.0 (video-analytics-2) — 2026-09-09
- 1.28.11-video-analytics.0 (video-analytics) — 2026-07-31
- 1.28.0-element-path-v1.0 (element-path-v1) — 2026-06-23
- 1.28.0-featelement-selector-v1.0 (featelement-selector-v1) — 2026-06-15
- 1.27.4-SR-4497-custom-transport-hooks.0 (SR-4497-custom-transport-hooks) — 2026-06-09
- 1.27.3-sr-perf-reliability-rc.0 (sr-perf-reliability-rc) — 2026-06-05
- 1.27.3-sr-4646-rc.0 (sr-4646-rc) — 2026-06-03
- 1.27.1-sr-idb-multitab-test-rc.0 (sr-idb-multitab-test-rc) — 2026-05-04
- 1.26.0-sr-3531-rc-2.0 (sr-3531-rc-2) — 2026-04-20
- 1.25.2-SR-3115-rc2.0 (SR-3115-rc2) — 2026-04-08
- 1.25.2-SR-3115-rc1.0 (SR-3115-rc1) — 2026-04-03
- 1.25.2-SR-3115.0 (SR-3115) — 2026-04-03
- … 154 more at https://npm.io/package/@amplitude/plugin-autocapture-browser/versions

## README

<p align="center">
  <a href="https://amplitude.com" target="_blank" align="center">
    <img src="https://static.amplitude.com/lightning/46c85bfd91905de8047f1ee65c7c93d6fa9ee6ea/static/media/amplitude-logo-with-text.4fb9e463.svg" width="280">
  </a>
  <br />
</p>

# @amplitude/plugin-autocapture-browser (beta)
**This plugin is in beta at the moment, naming and interface might change in the future.**

Browser SDK plugin for autocapture.

## Installation

This package is published on NPM registry and is available to be installed using npm and yarn.

```sh
# npm
npm install @amplitude/plugin-autocapture-browser@beta

# yarn
yarn add @amplitude/plugin-autocapture-browser@beta
```

## Usage

This plugin works on top of the Amplitude Browser SDK, generating auto-tracked events and sending to Amplitude.

**Shadow DOM:** optional support via remote config (`shadowDomEnabled`). See [SHADOW-DOM.md](./SHADOW-DOM.md).

To use this plugin, you need to install `@amplitude/analytics-browser` version `v1.9.1` or later.

### 1. Import Amplitude packages

* `@amplitude/analytics-browser`
* `@amplitude/plugin-autocapture-browser`

```typescript
import * as amplitude from '@amplitude/analytics-browser';
import { autocapturePlugin } from '@amplitude/plugin-autocapture-browser';
```

### 2. Instantiate the plugin

The plugin accepts 1 optional parameter, which is an `Object` to configure the allowed tracking options.

```typescript
const plugin = autocapturePlugin({
  cssSelectorAllowlist: [
    '.amp-tracking',
    '[amp-tracking]'
  ],
  pageUrlAllowlist: [
    'https://amplitude.com',
    new RegExp('https://amplitude.com/blog/*')
  ],
  pageUrlExcludelist: [
    'https://amplitude.com/admin',
    new RegExp('^https:\\/\\/amplitude\\.com\\/private\\/.*$')
  ],
});
```

Examples:
- The above `cssSelectorAllowlist` will only allow tracking elements like:
    - `<button amp-tracking>Click</button>`
    - `<a class="amp-tracking">Link</a>`
- The above `pageUrlAllowlist` will only allow the elements on URL "https://amplitude.com" or any URL matching the "https://amplitude.com/blog/*" to be tracked
- The above `pageUrlExcludelist` will block tracking on URL "https://amplitude.com/admin" or any URL matching the "^https:\\/\\/amplitude\\.com\\/private\\/.*$" pattern, even if they match the allowlist

#### Options

|Name|Type|Default|Description|
|-|-|-|-|
|`cssSelectorAllowlist`|`string[]`|`['a', 'button', 'input', 'select', 'textarea', 'label', '[data-amp-default-track]', '.amp-default-track']`| When provided, only allow elements matching any selector to be tracked. |
|`pageUrlAllowlist`|`(string\|RegExp)[]`|`undefined`| When provided, only allow elements matching URLs to be tracked. |
|`pageUrlExcludelist`|`(string\|RegExp)[]`|`undefined`| When provided, block tracking on elements matching URLs. Takes precedence over allowlist. |
|`shouldTrackEventResolver`|`(actionType: ActionType, element: Element) => boolean`|`undefined`| When provided, overwrite all other allowlists and configurations. |
|`dataAttributePrefix`|`string`|`'data-amp-track-'`| Allow data attributes to be collected in event property. |

### 3. Install plugin to Amplitude SDK

```typescript
amplitude.add(plugin);
```

### 4. Initialize Amplitude SDK

```typescript
amplitude.init('API_KEY');
```

---
_Source: https://npm.io/package/@amplitude/plugin-autocapture-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
