# GoogleAnalytics

Options for the Google Analytics 4 extension that tracks video engagement and playback events

Adds the Google Analytics 4 (GA4) [extension](https://videojs.org/docs/framework/react/guides/architecture) to the player. It renders nothing — place it anywhere inside the player, and it follows whatever media the player attaches, dispatching standard GA4 Enhanced Measurement video events and playback interaction events to `window.dataLayer`. See [Google Analytics](https://videojs.org/docs/framework/react/guides/google-analytics) for how telemetry works.

## Import

```bash
pnpm add @videojs/react @videojs/google-analytics
```

```tsx
import { GoogleAnalytics } from '@videojs/react/extensions/google-analytics';
```

## Anatomy

```tsx
<GoogleAnalytics />
```

## Options

| Prop | Type | Description |
| --- | --- | --- |
| `metadata` | `GoogleAnalyticsMetadata` | Video metadata and custom dimensions reported with GA4 events |
| `dataLayerName` | `string` | Name of the dataLayer array on `window`. Defaults to `'dataLayer'` |
| `disableProgress` | `boolean` | Disables 10%, 25%, 50%, and 75% progress milestones tracking. Defaults to `false` |
| `debug` | `boolean` | Logs telemetry events to the console. Defaults to `false` |
| `onEvent` | `(event: string, params: object) => void` | Callback to intercept dispatched events |

## Collection limits

Google Analytics 4 enforces collection limits on event parameters:

- **25 parameters per event**: The extension sends 8 standard parameters (`video_current_time`, `video_duration`, `video_percent`, `video_provider`, `video_stream_type`, `video_title`, `video_url`, and `visible`), leaving room for up to 17 custom dimensions in `metadata`.
- **Parameter names**: Up to 40 characters in length.
- **String values**: Up to 100 characters in length.

## See also

- [Google Analytics](https://videojs.org/docs/framework/react/guides/google-analytics): Configure GA4 video telemetry

---

React documentation: https://videojs.org/docs/framework/react/llms.txt
All documentation: https://videojs.org/llms.txt
