Skip to Content
Mux Docs: Home

Monitor Kaltura Web

This guide walks through integration with the Kaltura web player to collect video performance metrics with Mux data.

Features

The following data can be collected by the Mux Data SDK when you use the Kaltura Web SDK, as described below.

Supported Features:

  • Engagement metrics
  • Quality of Experience Metrics
  • Web metrics such as Player Startup Time, Page Load Time, etc
  • Average Bitrate metrics and renditionchange events
  • Request metrics
  • Custom Beacon Domain
  • Extraction of HLS Session Data
  • Live Stream Latency metric

1Install @mux/mux-data-kaltura

Include the Mux JavaScript SDK on every page of your web app that includes video.

npm install --save @mux/mux-data-kaltura

2Initialize Mux Data

Get your ENV_KEY from the Mux environments dashboard.

Env Key is different than your API token

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.

Under the Kaltura plugins option, pass in the mux configuration with key mux.

Log in to the Mux dashboard and find the environment that corresponds to your env_key and look for video views. It takes about a minute or two from tracking a view for it to show up on the Metrics tab.

If you aren't seeing data, check to see if you have an ad blocker, tracking blocker or some kind of network firewall that prevents your player from sending requests to Mux Data servers.

3Make your data actionable

The only required field in the options that you pass into @mux/mux-data-kaltura 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 data key, in the mux plugin configuration.

import initKalturaMux from "@mux/mux-data-kaltura";
initKalturaMux(KalturaPlayer);
var config = {
targetId: 'kalturaPlayer',
sources: {
progressive: [
{
mimetype: 'video/mp4',
url: 'https://muxed.s3.amazonaws.com/leds.mp4',
},
],
},
provider: {
partnerId: "<PARTNER ID>",
},
playback: {
autoplay: false,
},
plugins: {
mux: {
data: {
env_key: '<YOUR_ENV_KEY>', // required
// Metadata
player_name: 'Kaltura Player', // ex: 'My Main Player'
// ... and other metadata
},
},
},
};
KalturaPlayer.setup(config);

For more information, view Make your data actionable.

4Changing the video

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).

Note: You do not need to change the video info when changing to a different source of the same video content (e.g. different resolution or video format).

New source

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

See metadata in Make your data actionable for the full list of video details you can provide. You can include any metadata when changing the video but you should only need to update the values that start with video_.

It's best to change the video info immediately after telling the player which new source to play.

// player is the instance returned by the `KalturaPlayer.setup` function
player.mux.emit('videochange', {
video_id: 'abc345',
video_title: 'My Other Great Video',
video_series: 'Weekly Great Videos',
// ...
});

New Program

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. An example of this is a live stream that streams multiple programs back to back, with no interruptions.

In this case, you emit a programchange event, including the updated metadata for the new program within the continuous stream. This will remove all previous video data and reset all metrics for the video view, creating a new video view. See Metadata for the list of video details you can provide. You can include any metadata when changing the video but you should only need to update the values that start with video.

Note: The programchange event is intended to be used only while the player is currently not paused. If you emit this event while the player is paused, the resulting view will not track video startup time correctly, and may also have incorrect watch time. Do not emit this event while the player is paused.

// player is the instance returned by the `KalturaPlayer.setup` function
player.mux.emit('programchange', {
video_id: 'abc345',
video_title: 'My Other Great Video',
video_series: 'Weekly Great Videos',
// ...
});

5Advanced options

Disable cookies

By default, Mux plugins for HTML5-based players use a cookie to track playback across subsequent page views. This cookie includes information about the tracking of the viewer, such as an anonymized viewer ID that Mux generates for each user. None of this information is personally-identifiable, but you can disable the use of this cookie if desired. For instance, if your site or application is targeted towards children under 13, you should disable the use of cookies.

This is done by setting disableCookies: true in the options passed to the Mux plugin.

var kalturaPlayer = KalturaPlayer.setup({
// ...
plugins: {
mux: {
debug: false,
disableCookies: true,
data: {
env_key: "ENV_KEY",
// ...
}
}
}
});

Over-ride 'do not track' behavior

By default, @mux/mux-data-kaltura does not respect Do Not Track when set within browsers. This can be enabled in the options passed to Mux, via a setting named respectDoNotTrack. The default for this is false. If you would like to change this behavior, pass respectDoNotTrack: true.

var kalturaPlayer = KalturaPlayer.setup({
// ...
plugins: {
mux: {
respectDoNotTrack: true,
data: {
env_key: "ENV_KEY",
// ...
}
}
}
});

Customize error tracking behavior

Errors are fatal

Errors tracked by mux are considered fatal meaning that they are the result of playback failures. If errors are non-fatal they should not be captured.

By default, @mux/mux-data-kaltura will track errors emitted from the video element as fatal errors. If a fatal error happens outside of the context of the player, you can emit a custom error to the mux monitor.

// player is the instance returned by the `KalturaPlayer.setup` function
player.mux.emit('error', {
player_error_code: 100,
player_error_message: 'Description of error',
player_error_context: 'Additional context for the error'
});

When triggering an error event, it is important to provide values for player_error_code and player_error_message. The player_error_message should provide a generalized description of the error as it happened. The player_error_code must be an integer, and should provide a category of the error. If the errors match up with the HTML Media Element Error, you can use the same codes as the corresponding HTML errors. However, for custom errors, you should choose a number greater than or equal to 100.

In general you should not send a distinct code for each possible error message, but rather group similar errors under the same code. For instance, if your library has two different conditions for network errors, both should have the same player_error_code but different messages.

The error message and code are combined together and aggregated with all errors that occur in your environment in order to find the most common errors that occur. To make error aggregation as useful as possible, these values should be general enough to provide useful information but not specific to each individual error (such as stack trace).

You can use player_error_context to provide instance-specific information derived from the error such as stack trace or segment-ids where an error occurred. This value is not aggregated with other errors and can be used to provide detailed information. Note: Please do not include any personally identifiable information from the viewer in this data.

Error translator

If your player emits error events that are not fatal to playback or the errors are unclear and/or do not have helpful information in the default error message and codes you might find it helpful to use an error translator or disable automatic error tracking all together.

function errorTranslator (error) {
return {
player_error_code: translateCode(error.player_error_code),
player_error_message: translateMessage(error.player_error_message),
player_error_context: translateContext(error.player_error_context)
};
}
var kalturaPlayer = KalturaPlayer.setup({
// ...
plugins: {
mux: {
errorTranslator,
data: {
env_key: "ENV_KEY",
// ...
}
}
}
});

If you return false from your errorTranslator function then the error will not be tracked. Do this for non-fatal errors that you want to ignore. If your errorTranslator function itself raises an error, then it will be silenced and the player's original error will be used.

Disable automatic error tracking

In the case that you want full control over what errors are counted as fatal or not, you may want to consider turning off Mux's automatic error tracking completely. This can be done by passing automaticErrorTracking: false in the configuration object.

var kalturaPlayer = KalturaPlayer.setup({
// ...
plugins: {
mux: {
automaticErrorTracking: false,
data: {
env_key: "ENV_KEY",
// ...
}
}
}
});

Ads tracking with @mux/mux-data-kaltura

Mux supports Kaltura's playkit-js-ima plugin for pre-, mid-, and post-roll ads. Simply configure these plugins as you would normally, and Mux will track ads automatically. No additional configuration is needed.

Other Kaltura ad integrations have not been tested, but may work out of the box. Please contact us with any questions.

Release notes

Current release

v1.7.0

  • Target ES5 for bundles and validate bundles are ES5

  • Update mux-embed to v5.1.0

Previous releases

v1.6.5

  • Update mux-embed to v5.0.0

v1.6.4

  • Update mux-embed to v4.30.0

v1.6.3

  • Update mux-embed to v4.29.0

v1.6.2

  • Update mux-embed to v4.28.1

v1.6.1

  • Update mux-embed to v4.28.0

v1.6.0

  • fix an issue where seek latency could be unexpectedly large

  • fix an issue where seek latency does not include time at end of a view

  • Update mux-embed to v4.27.0

v1.5.3

  • Update mux-embed to v4.26.0

v1.5.2

  • Update mux-embed to v4.25.1

v1.5.1

  • Update mux-embed to v4.25.0

v1.5.0

  • Fix an issue where beacons over a certain size could get hung and not be sent

  • Update mux-embed to v4.24.0

v1.4.0

  • Fix an issue where tracking rebuffering can get into an infinite loop

  • Update mux-embed to v4.23.0

v1.3.5

  • Update mux-embed to v4.22.0

v1.3.4

  • Update mux-embed to v4.21.0

v1.3.3

  • Update mux-embed to v4.20.0

v1.3.2

  • Update mux-embed to v4.19.0

v1.3.1

  • Update mux-embed to v4.18.0

v1.3.0

  • Support player_error_context in errorTranslator

  • Update mux-embed to v4.17.0

v1.2.0

  • Adds support for new and updated fields: renditionchange, error, DRM type, dropped frames, and new custom fields

  • Update mux-embed to v4.16.0

v1.1.6

  • Record request_url and request_id with network events
  • Update mux-embed to v4.15.0

v1.1.5

  • Update mux-embed to v4.14.0

v1.1.4

  • Update mux-embed to v4.13.4

v1.1.3

  • Update mux-embed to v4.13.3

v1.1.2

  • Update mux-embed to v4.13.2

v1.1.1

  • Update mux-embed to v4.13.1

v1.1.0

  • Upgraded internal webpack version

  • Update mux-embed to v4.13.0

v1.0.14

  • Publish package to NPM

v1.0.13

  • Update mux-embed to v4.12.1

v1.0.12

  • Update mux-embed to v4.12.0

v1.0.11

  • Update mux-embed to v4.11.0

v1.0.10

  • Update mux-embed to v4.10.0

v1.0.9

  • Update mux-embed to v4.9.4

v1.0.8

  • Update mux-embed to v4.9.3

v1.0.7

  • Update mux-embed to v4.9.2

v1.0.6

  • Update mux-embed to v4.9.1

v1.0.5

  • Update mux-embed to v4.9.0

v1.0.4

  • Update mux-embed to v4.8.0

v1.0.3

  • Update mux-embed to v4.7.0

v1.0.2

  • Update mux-embed to v4.6.2

v1.0.1

  • Update mux-embed to v4.6.1

v1.0.0

  • Bump mux-embed to 4.6.0

v1.0.0-beta.1

  • Update mux-embed to v4.4.2 to support latency metrics

v1.0.0-beta.0

  • First beta release of the Kaltura SDK for web

Was this page helpful?