# Monitor NexPlayer

Connect Mux Data to NexPlayer to collect playback performance metrics. Use this guide when your web application plays video with the NexPlayer HTML5 SDK. NexPlayer manages this integration.

### In this guide:
1. [Install NexPlayer_HTML5_Mux](/content/docs/guides/monitor-nexplayer#1-install-nexplayer_html5_mux/index.html)  
2. [Initialize Mux Data](/content/docs/guides/monitor-nexplayer#2-initialize-mux-data/index.html)  
3. [Make your data actionable](/content/docs/guides/monitor-nexplayer#3-make-your-data-actionable/index.html)  
4. [Changing the video](/content/docs/guides/monitor-nexplayer#4-changing-the-video/index.html)  
5. [Advanced options](/content/docs/guides/monitor-nexplayer#5-advanced-options/index.html)

Mux Data collects playback performance metrics from NexPlayer. Use this guide when your web application plays video with the NexPlayer HTML5 SDK and you want to monitor the playback experience of your viewers. NexPlayer manages this integration. You do not need Mux Video to use Mux Data.

## [Third-party integration](/content/docs/guides/monitor-nexplayer#third-party-integration/index.html)

This integration is managed and operated by [NexPlayer](https://github.com/NexPlayer/NexPlayer_HTML5_Mux). Feedback should be made on the GitHub repo's [Issues](https://github.com/NexPlayer/NexPlayer_HTML5_Mux/issues) page or by contacting NexPlayer support by [email](mailto:supportmadrid@nexplayer.com).

## [1. Install NexPlayer_HTML5_Mux](/content/docs/guides/monitor-nexplayer#1-install-nexplayer_html5_mux/index.html)

Add the NexPlayer_HTML5_Mux plugin to your project by cloning the [GitHub repo](https://github.com/NexPlayer/NexPlayer_HTML5_Mux) or installing using yarn/npm.

## [2. Initialize Mux Data](/content/docs/guides/monitor-nexplayer#2-initialize-mux-data/index.html)

Get your `ENV_KEY` from the [Mux environments dashboard](https://dashboard.mux.com/environments).

`ENV_KEY` is a client-side key used for Mux Data monitoring. These are not to be confused with API tokens which are created in the admin settings dashboard and meant to access the Mux API from a trusted server.

Add NexPlayer as you normally would to your solution including recommended CSS styling. In addition, you will need to import the Mux SDK and `NexMuxHandShake.js` into the `<head />` and set the `window.muxPlayerInitTime` to the current date/time.

## [NexPlayer minimum version](/content/docs/guides/monitor-nexplayer#nexplayer-minimum-version/index.html)

Be sure to use the NexPlayer SDK v5.5.3.1 as it contains necessary functionality to integrate with Mux.

## [3. Make your data actionable](/content/docs/guides/monitor-nexplayer#3-make-your-data-actionable/index.html)

The only required field in the options that you pass into the NexPlayer_HTML5_Mux plugin is `ENV_KEY`. But without some metadata the metrics in your dashboard will lack the necessary information to take meaningful actions. Metadata allows you to search and filter on important fields in order to diagnose issues and optimize the playback experience for your end users.

Pass in metadata under the `muxConfiguration` on initialization.

## [4. Changing the video](/content/docs/guides/monitor-nexplayer#4-changing-the-video/index.html)

There are two cases where the underlying tracking of the video view need to be reset:
1. **New source:** When you load a new source URL into an existing player.
2. **New program:** When the program within a singular stream changes (such as a program change within a continuous live stream).

### [New source](/content/docs/guides/monitor-nexplayer#new-source/index.html)

If your application plays multiple videos back-to-back in the same video player, you need to signal when a new video starts to the Mux SDK. Examples of when this is needed are:
- The player advances to the next video in a playlist
- The user selects a different video to play

In order to signal the Mux SDK that a new view is starting, you will need to emit a `videochange` event, along with metadata about the new video.

### [New program](/content/docs/guides/monitor-nexplayer#new-program/index.html)

In some cases, you may have the program change within a stream, and you may want to track each program as a view on its own. In this case, you emit a `programchange` event, including the updated metadata for the new program within the continuous stream.

## [5. Advanced options](/content/docs/guides/monitor-nexplayer#5-advanced-options/index.html)

### [Disable cookies](/content/docs/guides/monitor-nexplayer#disable-cookies/index.html)

By default, Mux plugins for HTML5-based players use a cookie to track playback across subsequent page views in order to understand viewing sessions. This cookie includes information about the tracking of the viewer. This is done by setting `disableCookies: true` in the options.

### [Over-ride 'do not track' behavior](/content/docs/guides/monitor-nexplayer#over-ride-do-not-track-behavior/index.html)

By default, Mux plugins for HTML5-based players do not respect [Do Not Track](https://www.eff.org/issues/do-not-track) when set within browsers. If you would like to change this behavior, pass `respectDoNotTrack: true`.

### [Disable automatic error tracking](/content/docs/guides/monitor-nexplayer#disable-automatic-error-tracking/index.html)

This can be done by passing `automaticErrorTracking: false` in the configuration object.

### [Customize beacon collection domain](/content/docs/guides/monitor-nexplayer#customize-beacon-collection-domain/index.html)

If you have [integrated a custom domain for Data collection](/content/docs/guides/integrate-a-data-custom-domain/index.html), specify your custom domain by setting `beaconCollectionDomain`.
