Media analytics
What you learn​
You're instantiating DIVA Player in your web front-end and relying on DIVA Back Office as the video streaming source.
The goal of this article is to build the simplest front-end to stream a video from the DIVA Back Office with active Conviva and Youbora media analytics.
Before starting​
- Ensure the DIVA Back Office instance you rely on is up and running.
- Ask your video engineers team the
<video id>
and the related<settings URL>
. - Ensure the settings file contains the
mediaAnalytics
section:Based on your project requirements, the settings file only contains either the Conviva or Youbora configuration."mediaAnalytics": {
"conviva": {
"enabled": true,
"customerKey": "<yourCustomerKey>",
"playerName": "Diva",
"viewerId": "<yourViewerIdentifier>",
"cdnName": "Akamai",
"touchstoneUrl": "https://<yourSubdomain>.conviva.com"
},
"youbora": {
"enabled": true,
"playerName": "Diva",
"cdnName": "<yourCDNName>",
"userName": "<yourViewerIdentifier>",
"accountCode": "<yourAccountCode>"
}
}
Instantiation​
Media analytics code​
Enrich the Basic instantiation code with the media analytics configuration:
viewerId
: Viewer id passed down to media analytics platforms.userName
: User name passed down to media analytics platforms.playerVersion
: Player version passed down to media analytics platforms.cdnName
: CDN name parameter passed down to media analytics platforms.playerType
: Player type parameter passed down to media analytics platforms.mediaAnalyticsEventHandler
: Additional callback for media analytics events.customTag
: Custom tag generator.customDimensions
: Custom dimensions.
Code sample​
Write the media analytics configuration:
const mediaAnalyticsParam = {
viewerId: "DivaWebUser",
userName: "DivaWebUser",
playerVersion: getDivaVersion(),
cdnName: "AKAMAI",
playerType: "player",
mediaAnalyticsEventHandler: console.log,
customTag: () => {
return {
tag1Name: "<tag1Name>",
tagNName: "<tagNName>"
};
},
customDimensions: () => {
return ["<dimension1>", "<dimensionN>"];
},
};
Finally, add the mediaAnalyticsParam
to the DIVA Player instantiation:
<DivaWebBoAdapter
settingsURL={"<settingsURL>"}
languageCode={"en-US"}
config={config}
mediaAnalyticsParam={mediaAnalyticsParam}
/>
Working sample code (.tsx)​
import React from "react";
import { DivaWebBoAdapter } from "@deltatre-vxp/diva-sdk/diva-web-bo-adapter";
import "@deltatre-vxp/diva-sdk/diva-web-sdk/index.min.css";
const videoId = "<videoId>";
const libs = {
mux: "https://cdnjs.cloudflare.com/ajax/libs/mux.js/6.2.0/mux.min.js",
shaka: "https://cdnjs.cloudflare.com/ajax/libs/shaka-player/4.11.2/shaka-player.compiled.js",
hlsJs: "https://cdn.jsdelivr.net/npm/hls.js@1.5.7",
googleIMA: "https://imasdk.googleapis.com/js/sdkloader/ima3.js",
googleDAI: "https://imasdk.googleapis.com/js/sdkloader/ima3_dai.js",
googleCast: "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",
threeJs: "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.148.0/three.min.js",
};
const config = {
videoId: videoId,
libs: libs,
};
const mediaAnalyticsParam = {
viewerId: "DivaWebUser",
userName: "DivaWebUser",
playerVersion: getDivaVersion(),
cdnName: "AKAMAI",
playerType: "player",
mediaAnalyticsEventHandler: console.log,
customTag: () => {
return {
tag1Name: "<tag1Name>",
tagNName: "<tagNName>"
};
},
customDimensions: () => {
return ["<dimension1>", "<dimensionN>"];
},
};
const props = {
settingsUrl: "<Settings URL>",
languageCode: "en-US",
languageDictionary: "en-US",
onDivaBoAdapterError: console.error,
config: config,
 mediaAnalyticsParam: mediaAnalyticsParam
}
function App() {
return (
<DivaWebBoAdapter
{
...props
}
/>
);
}
export default App;