DCR Poland Video Browser SDK
From Engineering Client Portal
Overview
The Nielsen SDK is one of multiple framework SDKs that Nielsen provides to enable measuring linear (live) and on-demand TV viewing using TVs, mobile devices, etc. The Browser SDK is the framework for browsers developers to integrate Nielsen Measurement into their media player pages. It supports a variety of Nielsen Measurement Products like Digital in TV Ratings, Digital Content Ratings (DCR & DTVR), Digital Ad Ratings (DAR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events of pages like:
- Site launch events and how long page is viewed
- Time of viewing a sub section / page.
Please note:
The Browser SDK is intended to be used for native Browser implementations and cannot be used in a hybrid framework environment on Apps (Android, iOS) - eg. for Cordova. Only native webview implementations may work.
Prerequisites
In order to start using Nielsen's Browser SDK the following items are needed:
Item | Description | Source | |
---|---|---|---|
☑ | App ID (appid) | Unique ID assigned to the player/site and configured by product. | This will be provided upon starting the integration from Nielsen. |
Implementation
This guide covers implementation steps for utilizing the Standard Nielsen Browser SDK for DCR.
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");
</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("PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","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.
Key | Description | Values | Required |
---|---|---|---|
type | type of asset | "content" | ✓ |
assetid | unique ID assigned to asset (max 64 characters; only characters 0-9, a-z, A-Z underscore and minus are allowed - no special characters or vowel mutations) | custom (no Special Characters) | ✓ |
program | (string) name of program (max 254 characters) | custom | ✓ |
title | (string) episode title (max 254 characters) | custom - no backslash allowed in string (because of 3rd party data processing) | ✓ |
length | (int) length of content in seconds | 86400 seconds for live stream. For Event-Livestreams planned length. For VoD video length | ✓ |
airdate | The airdate in the linear TV. Original (local) air date and time (hh:mm:ss as 24h time stamp); if not known set it to eg. "19700101 00:00:00" | YYYY-MM-DDTHH:MI:SS YYYY-MM-DDHH:MI:SS (pass beginning of epoch if unknown) |
✓ |
isfullepisode | full episode flag | "y"- full episode, "n"- non full episode | ✓ |
adloadtype | type of ad load:
|
"2" - DCR measures content with dynamic ads |
✓ |
progen | program genre | custom | |
segB | custom segment | custom | |
segC | custom segment | custom | |
crossId1 | standard episode ID | custom | |
clientid |
parent ID – value is automatically populated through provided AppID. |
provided by Nielsen |
|
subbrand | vcid/sub-brand ID – value is automatically populated through provided AppID. In order to override the sub-brand configured to the AppID, value can |
provided by Nielsen |
Example Content Object
var contentMetadataObject =
{
type: 'content',
assetid: 'VID123-123456',
program: 'program name',
title: 'episode title',
length: 'length in seconds',
adloadtype: '2',
progen: 'SciFi', //Optional
segB: 'custom segment B', //Optional
segC: 'custom segment C', //Optional
airdate: 'YYYYMMDD HH:MI:SS',
isfullepisode: 'y'
};
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 asset (64 character limit; only characters 0-9, a-z, A-Z underscore and minus are allowed - no special characters or vowel mutations) | custom (no Special Characters) | ✓ |
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.
Note:
Avoid Carriage Return (CR) and/or Linefeeds (LF) in all fields!
Implementations have 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.
- For video content:
- Send loadMetadata with the same metadata and continue sending setPlayheadPosition once the playback resumes.
- For ads:
- just continue sending setPlayheadPosition 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 and after stop event when resuming video content (not after pausing and resuming an ad) |
'setPlayheadPosition' |
|
Pass playhead position every second during playback |
'stop' | playhead position in seconds | Call when ads complete playing and on pause event (when resume will be available). 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
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
- For type 'content' : Sending a "loadMetadata" event after a "stop" event will be handled by the SDK as a "resume", as long as the "assetid" and "type" are the same and not changed from the values before the "stop" event happened. Changing "assetid" value will lead into a new stream. Changing of "type" from "content" to "preroll" ("midroll", "postroll") will lead into a new object (ad) with that content stream. Changing any other parameter (eg. "program" or "title") for the content will not affect the reported content data (will stay as in the very first "content" metadata)
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 (such as Nielsen TV Ratings).
- A link to the Nielsen Digital Measurement Privacy Policy at https://www.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=pl.
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, such as Nielsen TV Ratings. 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://www.nielsen.com/legal/privacy-principles/digital-measurement-privacy-statement/?lang=pl.
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.
Turning off the First Party ID for Opt-out Users
The First Party ID(FPID) is enabled by default in the Browser SDK. For Opt-out users, the First Party ID can be turned off during the initialization of the SDK Instance, i.e. the parameter enableFpid can be set to "false" (FPID disabled) or "true" (FPID enabled).
Example of SDK Initialization with enableFpid
First Party ID turned on
nSdkInstance = NOLBUNDLE.nlsQ(appID, "videoSdkInstance", {
enableFpid: "true"
});
First Party ID turned off
nSdkInstance = NOLBUNDLE.nlsQ(appID, "videoSdkInstance", {
enableFpid: "false"
});
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("PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "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.