Skip to main content

Metrics

FL-Analytics is an add-on library that serves as a framework for recording comprehensive data metrics related to application, video playback, and user events. The library can also be used to collect custom events and metadata. The library's data model is based on the Data Dictionary which is the standard schema used to normalize every piece of data captured in order to generate many popular video streaming quality of experience metrics.

Setup

fl-analytics

  1. Add the following snippet to your index.html file.
<script src="fl-analytics.iife.js"></script>

Application Session

ApplicationSession provides the entry point to the library analytics protocols. It also serves as factory containing APIs to create other analytic sessions (PlaybackSession and UserSession). Besides this ApplicationSession also provides APIs for reporting app start and report fatal and non-fatal errors.

Create sessions using the relevant APIs (each parameter content, playbackSource, applicationContainer and userInfo is discussed in detail in below sections).

// Create application session instance
const appSession = flAnalytics.getApplicationSession();

// API to initialize appliction session instance
appSession.initialize({
configId: '<your-datazoom-key>',
application: appInfo,
device: deviceInfo,
user: userInfo,
customEventsConfigUrl: '<url-to-blacklisted-events-configuration>',
logger: '<application-logger>'
});

// API to create PlaybackSession
const playbackSession = appSession.createPlaybackSession(content, playbackSource, applicationContainer);

// API to create UserSession
const userSession = appSession.createUserSession(userInfo);
note

Since ApplicationSession is a singleton class, flAnalytics.getApplicationSession() should be called only once. In case multiple calls are made to the API it will always return the same instance. Also note that ApplicationSession acts as a factory to create the remaining analytic session instances(UserSession and PlaybackSession).

The library supports connection to multiple analytics provider (supports Datazoom at present) by create configuration to specific analytic provider, below is the one for creating configuration for datazoom.

Reporting Data

The Metadata that is expected to remain constant for the entire duration of a session should be provided as an application, user, subscription or device information object. They encapsulate all relevant optional and mandatory metadata regarding different aspects of the analytics session.

note

Use API to update any of this common reporting data.

Application

Create application reporting data payload.

NameTypeRequiredDescription
namestringtrueThe name of the application.
versionstringtrueThe version of the application.
buildVersionstringtrueThe build version of the application.
productstringfalseThe customer product.
User

Create user's reporting data payload.

NameTypeRequiredDescription
typeUserTypetrueIndicates appropriate user type.
idstringfalseThe unique user identifier (eg: Customer Id)
subscriptionSubscriptionfalseUser subscription details.
profileIdstringfalseThe unique identifier for the user's profile
Subscription

Create Subscription reporting data payload which will be reported as part of above user's payload.

NameTypeRequiredDescription
idStringtrueThe unique subscription identifier for the user.
statusSubscriptionStatusfalseIndicates appropriate subscription status.
planstringfalseThe subscription plan type name.
planIDstringfalseThe subscription plan type id
Device

Create user device's reporting data payload.

NameTypeRequiredDescription
platformTypePlatformTypetrueRepresents how user consuming service (eg: APP, WEB)
customDeviceManufacturerstringfalseThe manufacturer of the user's device if available.
customDeviceNamestringfalseThe name of the device model if available.
const appInfo = {
name: 'Sample App Web',
version: '7.0.57',
build: '1.0.1'
}

const deviceInfo = {
platformType: flAnalytics.PlatformType.WEB,
customDeviceMfg: 'test mfg',
customDeviceName: 'my pc'
}

const userInfo = {
type: flAnalytics.UserType.SUBSCRIBED,
}

Initializing application session

Application session must be initialized before use. To initialize the application session, an object with the following properties must be passed as parameter.

Custom events reporting to the analytics server can be toggled on/off remotely. Passing the config end point URL, where the black-listed items are hosted, to the initialize method will restricts the reporting of black-listed custom events.

NameTypeRequiredDescription
configIdstringtrueDatazoom configuration key.
applicationObjecttrueAn object containing the application information.
deviceObjecttrueAn object containing the device information.
userObjectfalseAn object containing the user information.
customEventsConfigUrlstringfalseThe end point where custom events configuration details are hosted.
loggerObjectfalseAn object with a custom logger.
// API to initialize application session instance
appSession.initialize({
configId: '<your-datazoom-key>',
application: appInfo,
device: deviceInfo,
user: userInfo,
customEventsConfigUrl: '<url-to-blacklisted-events-configuration>',
logger: '<application-logger>'
});

Standard Playback Events & Metrics

Create PlaybackSession to report player related events.

const playbackSession = appSession.createPlaybackSession(content, playbackSource, applicationContainer);

Attach Player

PlaybackSession provides and API called attachPlayer which takes a Player instance as parameter. This API enables the underlying analytics collection tool to access platform native player instance, therefore auto-reporting most of the playback related events.

playbackSession.attachPlayer(player);

Playback events that are auto-captured by library itself

NameDescription
playback_startThis event is reported when the video starts playing for the user.
heartbeatThis event is reported at periodic intervals (1 minute) during content playback.
media_requestThis event is reported after the user invokes playback.
player_readySignifies when the player has been initialized and is ready for playback.
pauseThis event is reported when the player is paused.
resumeThis event is reported when the user begins playing after pausing the video.
buffer_startBuffer Start identifies anytime the player has to wait for the video buffer to fill with video segments.
buffer_endEvent is reported when video starts playing again after a buffer is completed.
stall_startStall Start event is reported when playback of video stops because the buffer has been depleted causing an unexpected interruption for the user.
stall_endEvent reported when video starts playing again after a stall and the buffer has been replenished and playback resumes.
errorThrown if an error occurs during content playback or retrieval of the video.
playback_completeThis event signifies that the video player has reached the end of the currently playing content.
stopThis event is reported when the player has entered a stopped state.
milestoneReported when the playheadPosition passes a predetermined percentile milestone of the video's duration. Current milestones are fired at the 10, 25, 50, 75, 90 & 95 percentiles.
seek_startThis event records when the user interacts with time controls within the player to move forward or backward in the video timeline.
see_endEvent is reported when the player stops moving the playhead position to jump to a specific point on the timeline.
playingThe media is no longer blocked from playback, and has started playing. Reported when playback resumes from Stall, Buffering or Seek.

Report Custom Playback Events

note

The Web implementation of FL-Analytics library provides support for multiple concurrent playback event reporting.

Report Playback Start

PlaybackSession provides API to report playback_request event.

PlaybackRequest
Content Specific metadata

Create data payload for specific type of contents as below.

SportContent

Create SportContent reporting data payload that is specific to sport event.

NameTypeRequiredDescription
idStringtrueThe unique identifier for content item.
typeStringtrueThe type of content to report.
nameStringtrueThe content name from CMS.
providerIdStringfalseThe content's provider identifier.
genreStringfalseThe genre of the content.
licenseWindowStartDateStringfalseThe license window start date. The clear content may not have this parameter.
sportNameStringtrueThe name of the sport.
leagueNameStringtrueThe name of the sport league.
team1NameStringtrueThe name of the first sport team.
team2NameStringtrueThe name of the second sport team.
leagueIDStringfalseThe unique identifier of the sport league.
leagueExternalIDStringfalseThe external unique identifier of the sport league.
leagueShortNameStringfalseThe short name of the sport league.
gameIDStringfalseThe unique identifier of the sport game.
gameExternalIdStringfalseThe external unique identifier of the sport game.
venueSportVenuefalseThe SportVenue instance.
team1IDStringfalseThe unique identifier of the first sport team.
team1ExternalIDStringfalseThe external unique identifier of the first sport team
team1ShortNameStringfalseThe short name of the first sport team.
team2IDStringfalseThe unique identifier of the second sport team.
team2ExternalIDStringfalsehe external unique identifier of the second sport team.
team2ShortNameStringfalseThe short name of the second sport team.
SportVenue

Create SportVenue reporting data payload that is specific to sport event.

NameTypeRequiredDescription
venueNameStringtrueThe name of the sport event venue.
venueCityStringtrueThe city where the sport event takes place.
venueCountryStringtrueThe country where the sport event takes place.
TVShow

Create TVShow reporting data payload that is specific to TV show.

NameTypeRequiredDescription
idStringtrueThe unique identifier for content item.
typeStringtrueThe type of content to report.
nameStringtrueThe content name from CMS.
providerIdStringfalseThe content's provider identifier.
genreStringfalseThe genre of the content.
licenseWindowStartDateStringfalseThe license window start date. The clear content may not have this parameter.
seriesIDStringtrueThe unique identifier of the TV show series.
seriesNameStringtrueThe name of the TV show series.
seriesNumberStringtrueThe season number of the TV show series.
episodeNumberStringtrueThe number of one of the episodes in the TV show series.
MiscellaneousContent

Create MiscellaneousContent video content reporting data payload that belongs to categories other than SportContent or TVShow.

NameTypeRequiredDescription
idStringtrueThe unique identifier for content item.
typeStringtrueThe type of content to report.
nameStringtrueThe content name from CMS.
providerIdStringfalseThe content's provider identifier.
genreStringfalseThe genre of the content.
licenseWindowStartDateStringfalseThe license window start date. The clear content may not have this parameter.
ApplicationContainer

Create ApplicationContainer reporting data payload related to application container.

NameTypeRequiredDescription
idStringtrueThe unique identifier of the carousel where the content or link to the collection is located.
nameStringtrueThe name of the carousel where the content or link to the collection is located.
const container = {
id: '456',
name: 'Movies'
}

const content = {
id: '5FB9F75D-EC44-4ACB-925E-84EBC303F47E',
type: 'trailer',
name: 'Entre gemelos anda el juego',
providerId: 'magnolia',
genre: 'Horror',
seriesName: 'Seinfeld',
seriesId: 'PYA1002904',
seasonNumber: '2',
episodeNumber: '5',
licenseWindowStartDate: '2022-02-01 18:54:55.836 UTC'
}

const playbackSource = 'Carousel';

Handling Playback Request Interruptions

Any interruptions prior to starting the playback (before creating a player) can be reported using PlaybackSession API. Example: Checks related to content authorization (content authentication, parental controls etc)

// report interruption start
const customEvent = {
event: 'content_authorization_started',
data: {
'key1': 'value1',
'key2': 'value2'
}
}

playbackSession.interruptStart(customEvent);

// report interruption end
const customEvent = {
event: 'content_authorization_success',
data: {
'key1': 'value1',
'key2': 'value2'
}
}

playbackSession.interruptEnd(customEvent);

Configure Playback Metadata

Add Playback custom metadata

PlaybackSession provides an API that adds/updates common metadata to be reported across all playback related events.

playbackSession.setMetadata({
'key1': 'value1',
'key2': 'value2'
});

Report Playback Error

To report any error caused like content-auth failure, concurrent streams max limit reached (failure from server but not from player layer as FL-Analytics auto-reports player errors) can be reported using stop API in PlaybackSession. Send Error as a parameter(optional) to report playback stop on any error.

playbackSession.stop(error);

Value Added Events and Metrics

Application Events

Report Application start

ApplicationSession provides an API to report app_start event along with app start time.

// the time, in milliseconds, it takes to start the application
appSession.start(3000);

Report Application End

ApplicationSession provides an API to report app_end event.

appSession.stop();

User Events

UserSession provides the following API to report user action based events.

// Called when [User] executes "signup" flow.
userSession.signup(userInfo)

// Called when [User] executes "login" flow.
userSession.login(userInfo)

// Called when [User] executes "logout" flow.
userSession.logout(userInfo)

// Called when [User] executes "create profile" flow.
userSession.createProfile(userInfo)

// Called when [User] executes "update profile" flow.
userSession.updateProfile(userInfo)

// Called when [User] executes "start subscription" flow.
userSession.startSubscription(userInfo)

// Called when [User] executes "purchase subscription" flow.
userSession.purchaseSubscription(userInfo)

// Called when [User] executes "change subscription" flow.
userSession.changeSubscription(userInfo)

// Called when [User] executes "complete payment" flow.
userSession.completePayment(userInfo)
note

It is client application responsibility to ensure that each user action is triggered in the correct sequence.

Report Custom Events

ApplicationSession provides an API to report custom events.

const customEvent = {
event: 'sample_event',
data: {
'key1': 'value1',
'key2': 'value2'
}
}

appSession.addEvent(customEvent);
note
  1. In order to conform to the existing reporting scheme the event name should be provided in the lower case format and words should be separated by the underscore character e.g."playback_request"
  2. In Datazoom, any custom event will be reported as event name with custom_ prefix. (eg: playback_start as custom_playback_start) :::

When trying to report a custom event with a name that is already reserved (the list of reserved event names is captured by QP_ANALYTICS_EVENTS), library will throw an error. :::

Configure Application Metadata

Set Application custom metadata

Additional metadata that is to be added or updated to all application / playback / user events can be done using the below API. All subsequent events will report this additional data once it is defined.

appSession.setMetadata({
'key1': 'value1',
'key2': 'value2'
});

Application Errors

ApplicationSession provides APIs to report both fatal and non-fatal errors.

Report Fatal errors

Any application fatal error can be reported using below API. Send Error as a parameter(optional) to report playback stop on any error.

applicationSession.stop(error)

Report Non-fatal errors

Any application non-fatal error can be reported using below API. Send Error to report playback stop on any error.

applicationSession.addErrorEvent(error)

User Action Errors

Any User error can be reported using below API. Create UserError reporting data payload in case where one of user's action fails and User attribute along with it.

Create User Error

NameTypeRequiredDescription
codeStringtrueThe unique error code.
messageStringtrueThe message describing the error.
descriptionStringfalseThe contextual description of the error.
const userError = {
code: '745',
message: 'user action failure',
description: 'user action failure details'
}

Out-of-box Player Metrics

The Quickplay Player provides number of key metrics to analyse the playback performance. Please refer the bundled sample app to understand the corresponding metrics API.

Key Player Metrics

  • Load Latency - This is the number of seconds it took for the video element to have enough data to begin playback. This is measured from the time load() is called to the time the 'loadeddata' event is fired by then media element.

  • Buffer Range - Indicates how much is buffered ahead of the playhead and how much is buffered behind the playhead (in seconds).

  • Decoded Frames - The total number of frames decoded by the Player.

  • Framerate - Provides number of Frames being displayed (per second).

  • Dropped Frames - The total number of frames dropped by the Player.

  • Corrupted Frames - The total number of corrupted frames dropped by the browser.

  • Play Time - The total time spent in a playing state in seconds.

  • Pause Time - The total time spent in a paused state in seconds.

  • License Time - The time spent on license requests during this session in seconds, or NaN.

  • Buffering Time - The total time spent in a buffering state in seconds.

  • Required Bandwidth - The bandwidth required for the current streams (total, in bit/sec).

  • Estimated Bandwidth - The current estimated network bandwidth (in bit/sec).

  • Variant Bitrate - The bandwidth required to play active variant track, in bits/sec.

  • Video Bitrate - The total time spent in a buffering state in seconds.

  • Audio Bitrate - The bandwidth required for the current streams (total, in bit/sec).

  • Width - The width of the current video track.

  • Height - The height of the current video track.

The Quickplay Player's PlaybackStatistics provides all metric info required. For more information please refer sample app.

player.subscribe('progressupdate', function () {
console.log(player.playbackStatistics);
});