DCR India Video Browser SDK
From Engineering Client Portal
Overview
The Nielsen SDK is one of multiple framework SDKs that Nielsen provides to enable measuring live (beam) and on-demand (stream) content viewing using TVs, mobile devices, etc. The Browser SDK is the framework for browsers developers to integrate Nielsen Measurement into their media player pages.
Prerequisites
To get started, an AppID is needed. The AppID is a unique ID assigned to the player/site/app. This will be provided upon starting the integration from Nielsen.
apid: "XXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" // eg. PDA7D5EE6-B1B8-XXXX-XXXX-2A788BCXXXCA
Configure SDK
There are two steps required for configuring the SDK:
- Add Static Queue Snippet
- Create SDK Instance
Static Queue Snippet
Add the following script tag to the website:
<script>
!function(t,n)
{
t[n]=t[n]||
{
nlsQ:function(e,o,c,r,s,i)
{
return s=t.document,
r=s.createElement("script"),
r.async=1,
r.src=("http:"===t.location.protocol?"http:":"https:")+"//cdn-gl.imrworldwide.com/conf/"+e+".js#name="+o+"&ns="+n,
i=s.getElementsByTagName("script")[0],
i.parentNode.insertBefore(r,i),
t[n][o]=t[n][o]||{g:c||{},
ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]
}
}
}
(window,"NOLBUNDLE");
var nSdkInstance = NOLBUNDLE.nlsQ("PXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "nlsnInstance");
</script>
The static queue snippet allows the SDK APIs to be called while the actual SDK and configuration file are still being downloaded. As the queue can capture all API calls before the download completes, there is no wait time. Once the SDK is available, the API calls will transition from directing to the queue to the SDK seamlessly.
Create SDK Instance
To initialize the SDK, create an SDK instance by making the initialization call:
Initialization API Call
NOLBUNDLE.nlsQ("<apid>", "<instanceName>",{nol_sdkDebug: "debug"})
When creating an instance, pass the following three values:
Parameter | Description | Values |
---|---|---|
apid | Unique ID assigned to player/site | 'PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' |
instanceName | Name of SDK instance | "any string value" |
nol_sdkDebug | Enables Nielsen console logging. Only required for testing (not in production) | "{nol_sdkDebug: "debug"})" |
Example SDK Initialization
var nSdkInstance = NOLBUNDLE.nlsQ("PXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX", "nlsnInstance", {nol_sdkDebug: "debug"});
When the initialization call is made, a unique static configuration file, <apid>.js, will be downloaded based on the apid and will be cached on the user’s browser.
Once the configuration is downloaded, the SDK itself will be downloaded and initialized. All SDK modules are included in one file: “nlsSDK600.eu.bundle.min.js”.
Example SDK Configuration
The configuration should include the Static Queue Snippet and an SDK Instance for an unique AppID as shown in the example:
<script type="text/javascript">
// Add Static Queue Snippet
!function(t,n)
{
t[n]=t[n]||
{
nlsQ:function(e,o,c,r,s,i)
{
return s=t.document,
r=s.createElement("script"),
r.async=1,
r.src=("http:"===t.location.protocol?"http:":"https:")+"//cdn-gl.imrworldwide.com/conf/"+e+".js#name="+o+"&ns="+n,
i=s.getElementsByTagName("script")[0],
i.parentNode.insertBefore(r,i),
t[n][o]=t[n][o]||{g:c||{},
ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]
}
}
}
(window,"NOLBUNDLE");
// Created SDK Instance
var nSdkInstance = NOLBUNDLE.nlsQ("P14273221-CF5C-46BF-A832-994AEFB73AA4","myPlayerName", {nol_sdkDebug: "DEBUG"});
</script>
Create Metadata Objects
There are two types of asset metadata:
- content: identify video
- ad: identify each ad
The metadata received for each asset is used for classification and reporting.
Metadata can be passed through key-values using the Nielsen reserved keys. User will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.
Content Metadata
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.
Keys | Description | Example | Required |
---|---|---|---|
type | 'content', 'ad' |
'content' |
Yes |
assetid | unique ID assigned to asset | custom | Yes |
program | name of program (25 character limit) | custom | Yes |
title | name of program (40 character limit) | custom | Yes |
length | length of content in seconds | seconds (86400 for live stream) |
Yes |
isfullepisode | full episode flag | 'y'- full episode, 'n'- non full episode | Yes |
adloadtype | ad model (only pass value as 2) | '2' | Yes |
segB | custom segment B | custom | |
segC | custom segment C | custom | |
crossId1 | standard episode ID | custom | |
crossId2 | content originator (only required for distributors) | Nielsen provided |
Custom Parameters for Analytical Reporting Only
The below values will not be part of standard reporting and designed for custom analytical reporting only.
Keys | Parameter names | Description | Values | Example | Required/Obligatory | |
---|---|---|---|---|---|---|
nol_c0 | bc_lang | Language of the content | Language Code (64 codes) | '0001' |
Yes | |
nol_c1 | bc_adsupport | Ad Supported Flag | 'Y' or 'N' |
'Y' |
Yes | |
nol_c2 | bc_ugc | User Generated Content | 'Y' or 'N' |
'Y' |
Yes | |
nol_c4 | bc_sub | Subscribed or Free | 'S' or 'F' |
'S' |
Yes | |
nol_c5 | bc_download | Downloaded or Streamed content | 'D' or 'S' |
'D' |
Yes | |
nol_c7 | bc_ccat | Content code | ContentTypeID (10 codes) | '6' |
Yes | |
nol_c8 | bc_cgenre | Genre | BARC Custom Codes (81 codes) | 'F12' | Yes | |
nol_c9 | bc_do | Distributor or Owner | 'D' or 'O' |
'Y' |
Yes | |
nol_10 | bc_dname | Distributor name | BARC Predefined numeric/alphanumeric value | 'A123' | Yes | |
nol_c11 | bc_altype | Ad load type | '1' or '2' or '3' |
'1' |
Yes |
|
Note: nol_c3 and nol_c6 must not be set!
Example Content Object
var content_metadata_object = {
// SDK
type: 'content',
assetid: 'VID123-123456',
program: 'program name',
title: 'episode title',
length: '543',
isfullepisode: 'n',
adloadtype:'2',
//Custom Properties for Analysis
// Examples only
nol_c0: 'bc_lang,0001',
nol_c1: 'bc_adsupport,Y'
nol_c2: 'bc_ugc,Y',
nol_c4: 'bc_sub,S',
nol_c5: 'bc_download,S',
nol_c7: 'bc_ccat,6',
nol_c8: 'bc_cgenre,N1',
nol_c9: 'bc_do,D',
nol_c10: 'bc_dname,A123',
nol_c11: 'bc_altype,1'
}
Ad Metadata Object
The ad metadata should be passed for each individual ad.
Keys | Description | Values | Required |
---|---|---|---|
type | type of ad | 'preroll', 'midroll', or 'postroll' | ✓ |
assetid | unique ID assigned to ad | custom | ✓ |
Example Ad Object
var adMetadataObject =
{
assetid: 'AD-1',
type: 'preroll'
};
URL Character Limit: There is a URL character limit of 2K characters due to browser limitations. Exceeding this value could impair data delivery on particular browsers.
Avoid Carriage Return (CR) and/or Linefeeds (LF) in all fields (because of current data reporting as CSV)!
Implementations has to filter out CR/LF with appropriate programming.
It's also a good idea to check and validate entries from other systems (eg. CMS, player) before simply copy them to the variables in metadata.
Call Nielsen APIs
The method for calling events is ggPM().
nSdkInstance.ggPM('event', parameter, ...);
Interrupt Scenarios
Pause Event
To indicate pause
- Call stop immediately and withhold sending playhead position.
- Start sending pings – loadMetadata and playheadPosition - once the playback resumes.
Other Interrupt Scenarios
The following possible browser interruption scenarios must be handled:
- Browser/Tab close
- Leaving the page to another destination
- Pressing the stop button
There are many cases where the player itself has the ability to detect such situations. If not, these interruption scenarios can be handled through JavaScript. The events that are called will depend on the asset being played (e.g. midroll vs. content).
var stopped = false;
function closePlayer() {
if (stopped) {return;}
stopped = true;
if (inMidroll) { // Only inside a midroll indicate <stop> for the ad
nSdkInstance.ggPM('stop', playheadPositionMidroll);
}
nSdkInstance.ggPM('end', playheadPositionContent); // Indicate <end> for the content
};
window.addEventListener("beforeunload", function (e) {
closePlayer(); // call nielsensdk with end/stop
});
window.addEventListener("pagehide", function (e) { // for iOS mobile "pagehide" recommended by apple
closePlayer(); // call nielsensdk with end/stop
});
Note: User may need to add code to support specific browser versions (e.g. older versions of Internet Explorer or covering Safari on mobile browsers ... you may use "onpagehide" event as well).
Call Nielsen APIs
The method for calling events is ggPM().
nSdkInstance.ggPM('event', parameter);
Events
The events are included in the table below:
Event name | Values to pass | Description |
---|---|---|
'loadMetadata' | content/ad metadata object | Needs to be called at the beginning of each content/ad metadata object |
'setPlayheadPosition' |
var currenttime = Math.round(newDate()/1000); |
Pass playhead position every second during playback |
'stop' | playhead position in seconds | Call when ads complete playing and at the very end of the stream. The playhead position must be passed when calling stop |
'end' | playhead position in seconds | This event has to be called once for the current video asset at the end of the playback.At the end of the content stream, if the user switches to another piece of content or when the browser is refreshed or closed. |
Note: Playhead position as integer
Note: 'setPlayheadPosition' has to be called every second (for livestream send the UTC timestamp, for vod send the time in seconds as integer)
Example Events
- Event: loadMetadata | Value Pass ( Object ): Content Metadata Object
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);
- Event: loadMetadata | Value Pass ( Object ): Pre-roll AD Metadata Object
nSdkInstance.ggPM('loadMetadata', prerollMetadataObject);
- Event: setPlayheadPosition | Value Pass ( Integer ): playheadPosition
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
- Event: stop | Value Pass ( Integer ): stopPlayheadPosition
nSdkInstance.ggPM('stop', stopPlayheadPosition);
- Event: end | Value Pass ( Integer ): endPlayheadPosition
nSdkInstance.ggPM('end', endPlayheadPosition);
SDK Event Lifecycle
The sample event lifecycle can be used as a reference for identifying the order for calling events.
without Ads
Event Lifecycle without ads:
Example without ads:
// START OF STREAM
nSdkInstance.ggPM('loadMetadata', contentMetadataObject); // must be called as start of stream
// CONTENT
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0 (or with seconds since 1970-01-01 00:00:00 in case of livestream)
... /*** pass playheads every second ***/
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);
// END OF STREAM
nSdkInstance.ggPM('end', endPlayheadPosition); // has to be called here at the end of the content
// endPlayheadPosition = lastPlayheadPosition
with Ads
Event Lifecycle with ads:
Example with ads:
// START OF STREAM
nSdkInstance.ggPM('loadMetadata', contentMetadataObject); // must be called as start of stream (even if 1st asset is preroll)
// PREROLL
nSdkInstance.ggPM('loadMetadata', prerollMetadataObject);
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0
... /*** pass playhead every second ***/
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); // end pre-roll stream
nSdkInstance.ggPM('stop', stopPlayheadPosition); // stopPlayheadPosition = lastPlayheadPosition
// CONTENT
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0 for the first segment (or with seconds since 1970-01-01 00:00:00 in case of livestream)
... /*** pass playhead every second ***/
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
// MIDROLL
nSdkInstance.ggPM('loadMetadata', midrollMetadataObject);
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0
... /*** pass playhead every second ***/
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); // end mid-roll stream
nSdkInstance.ggPM('stop', stopPlayheadPosition); // stopPlayheadPosition = lastPlayheadPosition
// CONTENT
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from where it left off before mid-roll (or with seconds since 1970-01-01 00:00:00 in case of livestream)
... /*** pass playhead every second ***/
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition);
nSdkInstance.ggPM('end', endPlayheadPosition); // has to be called here at the end of the content
// endPlayheadPosition = lastPlayheadPosition
// POSTROLL
nSdkInstance.ggPM('loadmetadata', postrollMetadataObject);
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition); // must be fired every second with playhead starting from 0
... /*** pass playhead every second ***/
nSdkInstance.ggPM('setPlayheadPosition', lastPlayheadPosition); // end post-roll stream
// END OF STREAM
nSdkInstance.ggPM('stop', stopPlayheadPosition); // stopPlayheadPosition = lastPlayheadPosition
- 'setPlayheadPosition' is used for calculating duration and must be passed every second. The final playhead position must be sent for the current asset being played before calling 'stop', 'end', or 'loadmetadata'.
- after an 'end' in case there is a new content played, there is a need to have another 'loadmetadata' again.
- For Ad, events must be called for each individual Ad. Each Ad playhead position should begin at ‘0’ when ad starts.
- When content has resumed following an ad break, the playhead position update must continue where previous content segment left off. The playhead position should be passed as a rounded number with no decimals.
- For pre-roll ads you have to call the loadMetadata event for content at the start of stream and after the preroll
Nielsen Opt-Out
The site must provide a means for the user to opt-out of, or opt back into, Nielsen Measurement. A user can opt-out if they would prefer not to participate in any Nielsen online measurement research. To implement the opt-out option, include the following two items in your privacy policy.
- A notice that the player includes proprietary measurement software that allows users to contribute to market research.
- A link to the Nielsen Digital Measurement Privacy Policy at https://priv-policy.imrworldwide.com/priv/browser/in/en/optout.html.
On the Nielsen Digital Measurement Privacy Policy page, users can click "Choices" to read more detailed information about the measurement software, learn about their options with regard to Nielsen measurement, and, if they do not want to participate in Nielsen Online Measurement, click a link to receive an opt-out cookie.
The following paragraph is a template for an opt-out statement.
The properties may feature Nielsen proprietary measurement software, which will allow users to contribute to market research. To learn more about the information that Nielsen software may collect and your choices with regard to it, please see the Nielsen Digital Measurement Privacy Policy at https://priv-policy.imrworldwide.com/priv/browser/in/en/optout.html."
Opt Back In
Once users have opted-out, they can choose to opt back into Nielsen Measurement at anytime by selecting the opt back in link on the Nielsen Digital Privacy Policy page. When a user selects the link, their opt-out cookie will be deleted and they will be able to be measured.
Going Live
Following Nielsen testing, users need to make a couple of updates to the initialization call to ensure that the site is being measured properly.
- Debug Logging: Disable logging by deleting
{nol_sdkDebug: 'debug'}
from initialization call.
Example Production Initialization Call
Refer to the production initialization call below:
var nSdkInstance = NOLBUNDLE.nlsQ("P14273221-CF5C-46BF-A832-994AEFB73AA4", "myPlayerName");
Note: before going live you have to inform Nielsen - this is necessary, because Nielsen team has to adjust internal configuration parameter to enable data collection. Without that notification no data will be collected and no data will be reported.