Introduction:
FastPix Video Data Core SDK monitors and analyzes HLS.js and DASH.js video players. Get instant insights into video performance with our monitoring features:
- Real-time stream analytics (manifest loading, segments, quality switches)
- Player performance data (startup time, buffering, quality)
- Network metrics (bandwidth, request timing)
- Error logs and diagnostics
- User interaction events
The SDK instantly collects and sends all metrics to the FastPix dashboard for easy viewing. Currently available as a JavaScript bundle, with TypeScript support coming soon.
Prerequisites:
Getting Started
To begin tracking your video analytics, you’ll need your FastPix workspace key. Here’s how to get it:
- Sign up or login to FastPix Dashboard.
- Navigate to the workspace page.
- Copy your preferred workspace key.
That’s it! You’re ready to integrate the SDK into your video player.
Step 1: Installation and Setup:
Install the SDK using npm or another package manager of your choice:
npm i @fastpix/video-data-core
Step 2: Import
import fastpixMetrix from "@fastpix/video-data-core";
Step 3: Basic Integration
Before using the FastPix Video Data Core SDK, ensure you have installed either HLS.js or DASH.js player libraries:
The workspace_id is a mandatory field that must be provided. Below are the
integration steps for both HLS.js and DASH.js players.
HLS.js Integration
import Hls from "hls.js";
import fastpixMetrix from "@fastpix/video-data-core";
const videoPlayerElement = document.getElementById("video-player");
const initializationTime = fastpixMetrix.utilityMethods.now();
const hlsPlayerInstance = new Hls();
hlsPlayerInstance.loadSource("YOUR_HLS_URL");
hlsPlayerInstance.attachMedia(videoPlayerElement);
const trackingData = {
workspace_id: "WORKSPACE_KEY",
player_name: "Main Video Player",
player_init_time: initializationTime,
video_title: "VIDEO_TITLE",
video_id: "VIDEO_ID",
viewer_id: "VIEWER_ID",
};
fastpixMetrix.tracker(videoPlayerElement, {
debug: false,
hlsjs: hlsPlayerInstance,
Hls: Hls,
data: trackingData,
});
DASH.js Integration
import dashjs from "dashjs";
import fastpixMetrix from "@fastpix/video-data-core";
const videoPlayerElement = document.getElementById("video-player");
const initializationTime = fastpixMetrix.utilityMethods.now();
const dashPlayerInstance = dashjs.MediaPlayer().create();
dashPlayerInstance.initialize(videoPlayerElement, "YOUR_DASH_URL", false);
const trackingData = {
workspace_id: "WORKSPACE_KEY",
player_name: "Main Video Player",
player_init_time: initializationTime,
video_title: "VIDEO_TITLE",
video_id: "VIDEO_ID",
viewer_id: "VIEWER_ID",
};
fastpixMetrix.tracker(videoPlayerElement, {
debug: false,
dashPlayer: dashPlayerInstance,
dashjs: dashjs,
data: trackingData,
});
Once the player has loaded the URL and playback has started, the SDK will begin tracking the analytics. After playback ends, you can view the complete analytics report on your FastPix dashboard.
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.
import fastpixMetrix from "@fastpix/video-data-core";
const videoPlayerElement = document.getElementById("video-player");
const initializationTime = fastpixMetrix.utilityMethods.now();
const trackingData = {
workspace_id: "WORKSPACE_KEY",
player_name: "Main Video Player",
player_init_time: initializationTime,
video_title: "Test Content",
video_id: "f01a98s76t90p88i67x",
viewer_id: "user12345",
video_content_type: "series",
video_stream_type: "on-demand",
custom_1: "",
custom_2: "",
};
fastpixMetrix.tracker(videoPlayerElement, {
debug: false,
data: trackingData,
});
Note:
Keep metadata consistent across different video loads to make comparison easier in the dashboard.
The SDK also accepts the following optional attributes. It passes each attribute through unchanged. If you omit an attribute, the report excludes it without returning an error.
Your application
application_name: "APPLICATION_NAME",
application_version: "APPLICATION_VERSION",
content_id: "CONTENT_ID",
device_id: "DEVICE_ID",
page_type: "PAGE_TYPE",
The viewer
viewer_plan: "VIEWER_PLAN",
viewer_plan_category: "VIEWER_PLAN_CATEGORY",
viewer_plan_status: "VIEWER_PLAN_STATUS",
The title
video_brand: "VIDEO_BRAND",
video_affiliate: "VIDEO_AFFILIATE",
video_creator_id: "VIDEO_CREATOR_ID",
video_description: "VIDEO_DESCRIPTION",
video_media_tags: "VIDEO_MEDIA_TAGS",
video_codec: "VIDEO_CODEC",
video_audio_codec: "VIDEO_AUDIO_CODEC",
video_dynamic_range_type: "VIDEO_DYNAMIC_RANGE_TYPE",
Delivery and playback capabilities
view_drm_level: "VIEW_DRM_LEVEL",
view_cdn_edge_pop: "VIEW_CDN_EDGE_POP",
view_cdn_origin: "VIEW_CDN_ORIGIN",
view_time_shift_enabled: true,
player_captions_enabled: true,
player_pip_enabled: true,
Step 5: Advanced Customization with FastPix Data SDK
| Attribute |
Description |
Type |
Example Usage |
disableCookies |
FastPix Data SDK uses cookies by default to track playback across page views and to identify unique viewers. If your application is not intended to collect cookies, you can disable this feature by setting disableCookies: true. This ensures that no cookies are set during the user’s session, enhancing privacy and compliance with user preferences. |
Boolean |
disableCookies: true |
respectDoNotTrack |
Set to true to honor users’ privacy preferences regarding the ‘Do Not Track’ setting. |
Boolean |
respectDoNotTrack: true |
automaticErrorTracking |
FastPix automatically tracks errors that occur during playback failures. To disable this feature, set automaticErrorTracking to false. This allows you to have more control over errors which are considered fatal and helps you manage error reporting according to your application’s needs. |
Boolean |
automaticErrorTracking: false |
debug |
Set to true to enable debug logs in the console for troubleshooting purposes. |
Boolean |
debug: true |
const videoPlayerElement = document.getElementById("video-player");
const trackingData = {
debug: true,
disableCookies: true,
respectDoNotTrack: true,
automaticErrorTracking: false,
data: {
workspace_id: "WORKSPACE_KEY",
},
};
fastpixMetrix.tracker(videoPlayerElement, trackingData);
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.
const videoPlayerElement = document.getElementById("video-player");
videoPlayerElement.fp.dispatch("error", {
player_error_code: 1024,
player_error_message: "Description of error",
player_error_context: "Additional context for the error",
});
Changing video streams in player
When your application plays multiple videos back-to-back in the same player, it’s essential to notify the FastPix SDK whenever a new video starts; possibly in scenarios like playlist content/ video series or any other video that user wants to play.
const videoPlayerElement = document.getElementById("video-player");
videoPlayerElement.fp.dispatch("videoChange", {
video_id: "abc345",
video_title: "My Other Great Video",
video_series: "Weekly Great Videos",
});
Detailed Usage:
For more detailed steps and advanced usage, please refer to our official documentation:
评论