# @snowplow/browser-plugin-media-tracking

> Audio/Video tracking for Snowplow

Latest version **4.10.3** (published 2026-11-07) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install @snowplow/browser-plugin-media-tracking
pnpm add @snowplow/browser-plugin-media-tracking
yarn add @snowplow/browser-plugin-media-tracking
bun add @snowplow/browser-plugin-media-tracking
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 4.10.3 |
| Published | 2026-11-07 |
| First published | 2022-01-11 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 594 |
| Author | Greg Leonard |
| Maintainers | cksnp, snowplow-analytics, cogsp |

## Links

- npm: https://www.npmjs.com/package/@snowplow/browser-plugin-media-tracking
- Repository: https://github.com/snowplow/snowplow-javascript-tracker
- Homepage: http://bit.ly/sp-js
- Issues: https://github.com/snowplow/snowplow-javascript-tracker/issues
- npm.io page: https://npm.io/package/@snowplow/browser-plugin-media-tracking

## Dependencies (5)

- [uuid](https://npm.io/package/uuid.md) ^11.1.1
- [tslib](https://npm.io/package/tslib.md) ^2.3.1
- [@snowplow/tracker-core](https://npm.io/package/@snowplow/tracker-core.md) 4.10.3
- [@snowplow/browser-plugin-media](https://npm.io/package/@snowplow/browser-plugin-media.md) 4.10.3
- [@snowplow/browser-tracker-core](https://npm.io/package/@snowplow/browser-tracker-core.md) 4.10.3

## Recent versions

- 4.10.3 (latest) — 2026-11-07
- 4.1.1-dev.2 (react-native) — 2025-01-02
- 4.0.2-dev.1 (create_react_native_tracker) — 2024-11-07
- 4.0.0-beta.4 (next) — 2024-10-22
- 3.13.2-dev.0 (1185-id-service-option) — 2023-07-04
- 3.13.1-dev.0 (add-tracking-scenario-option-to-core) — 2023-06-22
- 4.10.2 — 2026-09-09
- 4.10.1 — 2026-08-19
- 4.10.0 — 2026-07-27
- 4.9.0 — 2026-07-21
- 4.8.4 — 2026-07-02
- 4.8.3 — 2026-06-30
- 4.8.2 — 2026-06-17
- 4.8.1 — 2026-05-13
- 4.8.0 — 2026-04-28
- … 68 more at https://npm.io/package/@snowplow/browser-plugin-media-tracking/versions

## README

# Snowplow Media Tracking

[![npm version][npm-image]][npm-url]
[![License][license-image]](LICENSE)

Browser Plugin to be used with `@snowplow/browser-tracker`.

Adds HTML5 Video and Audio tracking events to your Snowplow tracking.

## Maintainer quick start

Part of the Snowplow JavaScript Tracker monorepo.
Build with [Node.js](https://nodejs.org/en/) (18 - 20) and [Rush](https://rushjs.io/).

### Setup repository

```bash
npm install -g @microsoft/rush
git clone https://github.com/snowplow/snowplow-javascript-tracker.git
rush update
```

### Package Installation

With npm:

```bash
npm install @snowplow/browser-plugin-media-tracking
```

## Usage

Initialize your tracker with the MediaTrackingPlugin:

```js
import { newTracker } from '@snowplow/browser-tracker';
import { MediaTrackingPlugin, startHtml5MediaTracking, endHtml5MediaTracking } from '@snowplow/browser-plugin-media-tracking';

newTracker('sp2', '{{collector}}', { plugins: [ MediaTrackingPlugin() ] }); // Also stores reference at module level
```

Then, use the `startHtml5MediaTracking` function described below to produce events from your HTML5 Video/Audio element(s).

```js
startHtml5MediaTracking({ video, id })
```

| Parameter | Type                     | Description                                                                            | Required |
| ----------| ------------------------ | -------------------------------------------------------------------------------------- | -------- |
| `id`      | `string`                 | A UUID identifier to use as the media session ID                                       | Yes      |
| `video`   | `string` / `HTMLElement` | The HTML id attribute, CSS selector, or actual media element to track media events for | Yes      |

See the [full documentation](https://docs.snowplow.io/docs/sources/trackers/web-trackers/tracking-events/media/html5/#starthtml5mediatracking) for optional parameters.

## Example Usage

```html
  ...
  <video id="my-video" src="my-video.mp4">
  ...
```

```js
import { startHtml5MediaTracking, endHtml5MediaTracking } from '@snowplow/browser-plugin-media-tracking';

const sessionId = crypto.randomUUID();

startHtml5MediaTracking({
  id: sessionId,
  video: 'my-video',
  label: "My Custom Video Label",
  boundaries: [10, 25, 50, 75],
});

/* ... */

endHtml5MediaTracking(sessionId);
```

 For a full list of parameters and trackable events, head over to the [docs page](https://docs.snowplow.io/docs/sources/trackers/web-trackers/tracking-events/media/html5/#events).

## Copyright and license

Licensed and distributed under the [BSD 3-Clause License](LICENSE) ([An OSI Approved License][osi]).

Copyright (c) 2022 Snowplow Analytics Ltd.

All rights reserved.

[npm-url]: https://www.npmjs.com/package/@snowplow/browser-plugin-form-tracking
[npm-image]: https://img.shields.io/npm/v/@snowplow/browser-plugin-form-tracking
[docs]: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/
[osi]: https://opensource.org/licenses/BSD-3-Clause
[license-image]: https://img.shields.io/npm/l/@snowplow/browser-plugin-form-tracking

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