Monitor Video.js
The FastPix Data SDK for Video.js monitors and analyzes key Video.js player metrics, providing actionable insights to optimize video streaming performance and deliver a smoother viewing experience.
Key features:
- See how users interact with your videos.
- Track real-time metrics like bitrate, buffering, startup, render quality, and failures.
- Get detailed error reports to quickly identify and fix playback issues.
- Customize tracking attributes to suit your business needs.
- View and compare metrics in one place to support data-driven decisions.
Installation and setup
Import the SDK
Basic integration
Enhance your tracking
Advanced configuration
Emit custom events
Step 1
Installation and setup
Step 2
Import the SDK
Step 3
Basic integration
Step 4
Enhance your tracking
Step 5
Advanced configuration
Step 6
Emit custom events
Prerequisites
To track and analyze video performance, initialize the FastPix Data SDK with your Workspace key.
-
Log into your FastPix dashboard and go to the Workspaces section.
-
Copy the Workspace Key for client-side monitoring. Include this key in your JavaScript code on every page where you want to track video performance.
Understand what is a Workspace.

Step 1: Installation and setup
This package can be installed using npm, a CDN, or your preferred package manager.
View GitHub repoUsing npm:
Using CDN:
NOTE
Ensure that a package based on Video.js Player is installed or accessible via a CDN.
Step 2: Import the SDK
Step 3: Basic integration
The workspace_id is a required field and must be included. Start by installing the video.js package and linking it to your HTML5 video element. Then, pass the videojs function (imported from the video.js library) along with your custom metadata to the initVideoJsTracking function.
Once the player has loaded the URL and playback has started, the SDK will then begin tracking the analytics.
After successfully completing Step 3, you can track viewer metrics in the FastPix dashboard once playback ends. Steps 4, 5, and 6 are optional and can be utilized as needed to enhance your integration.
Step 4: Enhance your tracking with user passable metadata
Check out the user-passable metadata documentation to see the metadata supported by FastPix. You can use custom metadata fields like custom_1 to custom_10 for your business logic, giving you the flexibility to pass any required values. Named attributes, such as video_title and video_id, can be passed directly as they are.
DEVELOPMENT TIP
Keep metadata consistent across different video loads to make comparison easier in your analytics dashboard.
Step 5: Advanced customization with FastPix Data SDK
Enhancing your video player with advanced options can significantly improve user experience and data tracking. Below are key configurations you can implement when using the FastPix SDK with your HLS.js player instance.
Example:
Step 6: Emit custom events
Advanced error reporting and contextual tracking
By default, FastPix tracks errors that occur during playback failures. However, you can also emit a custom error event for non-severe issues that arise outside of these failures, allowing you to provide additional context for tracking purposes.
TIP
Use custom error codes and messages that are meaningful for your debugging process to streamline troubleshooting.
Changing video streams
When playing multiple videos back-to-back, it’s important to notify the FastPix SDK whenever a new video starts to ensure accurate tracking. You should signal a new source in the following scenarios:
- The player advances to the next video in a playlist.
- The user selects a different video to play.
To inform the FastPix SDK of a new view, emit a videoChange event immediately after loading the new video source:
PLEASE NOTE
Always ensure that this event is dispatched right after the new source is loaded to maintain accurate tracking.
Example to configure Video.js with FastPix Data SDK
Here are platform-specific examples to help you integrate the FastPix Data SDK with your Video.js player. Use the following React or JavaScript or HTML code into your application:
Changelog
All notable changes to the Video.js Player Video Data SDK is documented below.
Current version
v1.0.6
Changed:
- Applied code quality fixes for improved maintainability and reliability:
- Replaced
windowreferences withglobalThis.windowfor safer global access. - Used
Number.parseIntinstead of the globalparseInt. - Hoisted nested helper functions (
determinePreloadType,defaultOnReadyStateChange,dispatchRequestCompleted,dispatchRequestFailed,createCallback,createBeforeRequestCallback,handleOnRequestStateChange) to reduce function nesting depth. - Replaced
Functiontype usages with explicit function signatures. - Added explanatory comments to intentionally empty
catchblocks. - Simplified conditional checks using optional chaining.
- Replaced
- Upgraded
@fastpix/video-data-core(FastPix Data Core SDK) to^1.0.8.
Previous versions
v1.0.5
Changed:
- Upgraded
@fastpix/video-data-core(FastPix Data Core SDK) to the latest version.
v1.0.4
Changed:
- Updated npm authentication from Classic token to Granular token for improved security and fine-grained permissions.
v1.0.3
- Updated
package.jsonto include additional keywords related to video.js monitoring.
v1.0.2
- Upgraded the Video Data Core SDK to the latest version.
- Updated readme.md with a redirection link for supported dimension parameters.
v1.0.1
- Bug fix to prevent calls to getPlayerState and getPlayheadTimeInMs after the player has been destroyed.
v1.0.0
Added:
- Integrated FastPix Data SDK with Video.js for performance tracking.
- Enables detailed insights into user engagement, playback quality, and real-time streaming diagnostics.
- Implemented robust error detection and reporting for Video.js-specific playback issues.
- Supports customizable behavior, such as disabling cookies, respecting
Do Not Tracksettings, and configuring advanced error handling. - Added custom metadata support to allow users to pass optional fields (
video_id,video_title,video_duration, etc.) for enhanced tracking and reporting. - Introduced event tracking for
videoChangeto handle metadata updates during playback transitions within Video.js.