Custom Analytics

The Blings SDK enables easy integration of your analytics solution, such as Google Analytics, Mixpanel, or Amplitude, with MP5 video playback.

By adding a small piece of code, you can track various video analytics, including events like "video is ready", button clicks, scene changes, play and pause, and more. All these analytics will be sent directly to your system.

By integrating the Blings SDK, you can easily analyze the behavior of users while they watch the video as part of the entire user journey, all within your existing tool set. This unified approach allows you to gain valuable insights and understand how users interact with the video content, and compare that to the results of this communication.

SDK custom analytics functions

Blings SDK requires three functions to set up analytics:

init - This function is used to set up the tool and pass the analytics token. It is called immediately.

config - This function is used to set parameters such as page and user ID. It is called once the player has received user data.

send - This is the main function that gets called for every playback event.

// custom analytics configuration object
{
	    init: ()=>{},   
	    config: (player)=>{}, 
	    send: (event, properties)=>{}
	}

You can use these functions in accordance with your analytics tool, as shown in this example that uses Mixpanel:

First, add the library script to your page, and then, set the analytics this in this way:

const customAnalytics = {
  init() {
    mixpanel.init("YOUR_MIXPANEL_TOKEN");
  },
  config(player) {
    mixpanel.register({
      userID: "xyz-123",
      userType: "customer",
    });
  },
  send(event, properties) {
    mixpanel.track(event, properties);
  },
};

Passing the analytics configuration to the SDK

To integrate your analytics platform, you have two options:

  1. Per Instance Configuration (Recommended): Set the customAnalytics configuration in the analyticsConfig property, inside settings property, when you call BlingsPlayer.create. (This configuration takes precedence over the global configuration)

  2. Global Configuration: Set BlingsPlayer.config.analytics function, that returns the configuration object, before running the BlingsPlayer.create function. This will set the custom analytics for each player created.

Integration Demo

Feel free to explore the provided demo and check the console for relevant logs to see how the events are being tracked.

Code pen integration demo

Documentation and Types:

configuration object

Events:

Event Definitions

๐Ÿ”น init

๐Ÿ“Œ Triggered When: The analytics system initializes.

๐ŸŽฏ Purpose: Marks the start of analytics tracking.

๐Ÿ“Š Example Data:

{

"category": "PAGE"

}

๐Ÿ”น loaded

๐Ÿ“Œ Triggered When: The player is fully loaded and ready to play.

๐ŸŽฏ Purpose: Confirms successful loading of all required assets.

๐Ÿ“Š Example Data:

{

"category": "PLAYBACK",

"value": "LOADED"

}

๐Ÿ”น scene-change

๐Ÿ“Œ Triggered When: The user navigates to a new scene.

๐ŸŽฏ Purpose: Tracks scene transitions.

๐Ÿ“Š Example Data:

{

"category": "PLAYBACK",

"value": "SCENE_2",

"label": "IntroScene"

}

๐Ÿ”น ended

๐Ÿ“Œ Triggered When: The video reaches its end.

๐ŸŽฏ Purpose: Identifies when a user watches the entire video.

๐Ÿ“Š Example Data:

{

"category": "PLAYBACK",

"value": "ENDED"

}

๐Ÿ”น play

๐Ÿ“Œ Triggered When: The user presses play.

๐ŸŽฏ Purpose: Tracks playback initiation.

๐Ÿ“Š Example Data:

{

"category": "PLAY_PAUSE",

"value": 120

}

๐Ÿ”น first-play

๐Ÿ“Œ Triggered When: The video plays for the first time.

๐ŸŽฏ Purpose: Differentiates initial play from other play events.

๐Ÿ“Š Example Data:

{

"category": "PLAYBACK",

"label": "USER_INTERACTION_NO_AUTO_PLAY",

"value": "FIRST_PLAY",

"payload": {

"initialScenes": ["IntroScene"],

"firstScene": "IntroScene"

}

}

๐Ÿ”น pause

๐Ÿ“Œ Triggered When: The video playback is paused.

๐ŸŽฏ Purpose: Tracks when a user stops playback.

๐Ÿ“Š Example Data:

{

"category": "PLAY_PAUSE",

"value": 150

}

๐Ÿ”น replay

๐Ÿ“Œ Triggered When: The user replays the video.

๐ŸŽฏ Purpose: Tracks when users restart the video.

๐Ÿ“Š Example Data:

{

"category": "PLAYBACK",

"value": "REPLAY"

}

๐Ÿ”น cta-click

๐Ÿ“Œ Triggered When: The user clicks a CTA button.

๐ŸŽฏ Purpose: Tracks conversion and user engagement.

๐Ÿ“Š Example Data:

{

"category": "PLAYBACK",

"value": "MAIN_CTA"

}

๐Ÿ”น sdk-loaded

๐Ÿ“Œ Triggered When: The SDK is fully initialized.

๐ŸŽฏ Purpose: Confirms the SDK is ready.

๐Ÿ”น loading-assets

๐Ÿ“Œ Triggered When: Additional assets (images, animations, etc.) are loading.

๐ŸŽฏ Purpose: Tracks the loading process for supporting assets.

๐Ÿ”น ready

๐Ÿ“Œ Triggered When: The player is fully ready for interaction.

๐ŸŽฏ Purpose: Indicates all required resources are loaded and functional.

๐Ÿ”น fingerprint

๐Ÿ“Œ Triggered When: A unique user identifier is generated.

๐ŸŽฏ Purpose: Ensures consistent user tracking across sessions.

๐Ÿ”น loaded-from

๐Ÿ“Œ Triggered When: Identifies the source from which the player was loaded.

๐ŸŽฏ Purpose: Tracks traffic sources (e.g., direct URL, referral).

๐Ÿ”น spinner-state

๐Ÿ“Œ Triggered When: The loading spinner appears or disappears.

๐ŸŽฏ Purpose: Tracks buffering states.

๐Ÿ”น InteractiveAnalyticsEvents

๐Ÿ“Œ Triggered When: Various interactive analytics events occur.

๐ŸŽฏ Purpose: A generic category for user interactions (clicks, hovers, swipes).

๐Ÿ”น wtr (Watch Time Range)

๐Ÿ“Œ Triggered When: The user watches a specific segment of the video.

๐ŸŽฏ Purpose: Tracks how much of the video was watched.

๐Ÿ“Š Example Data:

{

"category": "WATCH_TIME_RANGE",

"value": [30, 90],

"label": "IntroScene"

}

๐Ÿ”น error

๐Ÿ“Œ Triggered When: An error occurs in the player.

๐ŸŽฏ Purpose: Captures issues related to playback, assets, or analytics failures.

๐Ÿ“Š Example Data:

{

"type": "ANALYTICS",

"message": "Init of one or more analytics instances failed"

}

๐Ÿ”น html-id

๐Ÿ“Œ Triggered When: The playerโ€™s unique HTML element ID is referenced.

๐ŸŽฏ Purpose: Assists in debugging and tracking player instances.

๐Ÿ”น uid

๐Ÿ“Œ Triggered When: A unique user identifier is assigned.

๐ŸŽฏ Purpose: Ensures continuity of tracking for a user across sessions.

Last updated