DCR Thailand 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 (BSDK) is the framework for website developers to integrate Nielsen Measurement into their media players. Nielsen SDKs are also equipped to measure static content and can track key life cycle events.
Prerequisites
Before you start the integration, you will need:
Item | Description | Source | |
---|---|---|---|
☑ | App ID (apid) | Unique ID assigned to the player/site and configured by product. During initial implementation, a 'test' apid will be given. Once the implementation has been certified, a 'production' apid will then be generated and needs to be used before 'going live'. | Contact Nielsen |
Configure SDK
There are two steps required for configuring the SDK:
- Add Static Queue Snippet
- Create SDK Instance
Static Queue Snippet
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.
Add the following script tag to the website:
!function(e,n){
function t(e){
return"object"==typeof e?JSON.parse(JSON.stringify(e)):e
}
e[n]=e[n]||
{
nlsQ:function(o,r,c){
var s=e.document,
a=s.createElement("script");
a.async=1,
a.src=("http:"===e.location.protocol?"http:":"https:")+"//cdn-gl.imrworldwide.com/conf/"+o+".js#name="+r+"&ns="+n;
var i=s.getElementsByTagName("script")[0];
return i.parentNode.insertBefore(a,i),
e[n][r]=e[n][r]||{g:c||{},
ggPM:function(o,c,s,a,i){e[n][r].q=e[n][r].q||[];try{var l=t([o,c,s,a,i]);e[n][r].q.push(l)}
catch(e){console&&console.log&&console.log("Error: Cannot register event in Nielsen SDK queue.")}},
trackEvent:function(o){e[n][r].te=e[n][r].te||[];try{var c=t(o);e[n][r].te.push(c)}
catch(e){console&&console.log&&console.log("Error: Cannot register event in Nielsen SDK queue.")}}},
e[n][r]
}
}
}(window,"NOLBUNDLE");
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 values: (nol_sdkDebug
and optout
are optional)
Parameter | Description | Values |
---|---|---|
apid | Unique ID assigned to player/site |
'TXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX' - Test Apid that starts with 'T' |
instanceName | Name of SDK instance | "any string value" |
nol_sdkDebug | Enables Nielsen console logging if desired. | {nol_sdkDebug: "debug"}
{nol_sdkDebug: "info"}
{nol_sdkDebug: "warn"}
{nol_sdkDebug: "true"}
|
optout | Optional: OptOut global parameter. | 1/0 or true/false
|
Example SDK Initialization
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.
var nSdkInstance = NOLBUNDLE.nlsQ("XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX", "nlsnInstance", {
nol_sdkDebug: "debug",
optout: "false"
});
Once the configuration is downloaded, the SDK itself will be downloaded and initialized. All SDK modules are included in one file: “nlsSDK600.bundle.min.js”. More information on OptOut Parameter under Privacy and Opt-Out.
Example SDK Configuration
The configuration should include the Static Queue Snippet and an SDK Instance for an unique App ID as shown in the example:
<script type="text/javascript">
// Add Static Queue Snippet
!function(e,n){
function t(e){
return"object"==typeof e?JSON.parse(JSON.stringify(e)):e
}
e[n]=e[n]||
{
nlsQ:function(o,r,c){
var s=e.document,
a=s.createElement("script");
a.async=1,
a.src=("http:"===e.location.protocol?"http:":"https:")+"//cdn-gl.imrworldwide.com/conf/"+o+".js#name="+r+"&ns="+n;
var i=s.getElementsByTagName("script")[0];
return i.parentNode.insertBefore(a,i),
e[n][r]=e[n][r]||{g:c||{},
ggPM:function(o,c,s,a,i){e[n][r].q=e[n][r].q||[];try{var l=t([o,c,s,a,i]);e[n][r].q.push(l)}
catch(e){console&&console.log&&console.log("Error: Cannot register event in Nielsen SDK queue.")}},
trackEvent:function(o){e[n][r].te=e[n][r].te||[];try{var c=t(o);e[n][r].te.push(c)}
catch(e){console&&console.log&&console.log("Error: Cannot register event in Nielsen SDK queue.")}}},
e[n][r]
}
}
}(window,"NOLBUNDLE");
// Created SDK Instance
var nSdkInstance = NOLBUNDLE.nlsQ("XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX", "nlsnInstance", {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 entirety of an episode/clip including when ads play.
Key | Description | Values | Required |
---|---|---|---|
clientid |
parent ID – value is automatically populated through provided App ID. |
Nielsen provided |
|
subbrand | sub-brand ID – value is automatically populated through provided App ID. In order to override the sub-brand configured to the App ID, value can |
Nielsen provided |
|
type | type of asset | "content" | ✓ |
assetid | unique ID assigned to asset | custom (no Special Characters). The Content ID should be populated here which should correspond to the same value in the post transmission logs. |
✓ |
program | name of program | custom | ✓ |
title | episode name | custom | ✓ |
length | length of content in seconds | seconds (86400 for live stream) | ✓ |
segB | custom segment B. Custom segments can be used to aggregate content however you choose. Some examples include genre, category, or platform. | custom | |
segC | For VOD: Populate TVContent ID, For livestream: leave blank | custom | Required for VOD only |
isfullepisode | full episode flag |
Note: For livestream content with Dynamic Ad Insertion (DAI), the isfullepisode value should be set to 'y'. |
✓ |
adloadtype | type of Ad load:
|
|
✓ |
Example Content Object
var contentMetadataObject =
{
type: 'content',
assetid: 'VID-123456',
program: 'program name',
title: 'episode title',
length: 'length in seconds',
isfullepisode: 'y',
adloadtype: '2',
segB: 'custom segment B', // optional
segC: 'custom segment C', // optional
};
Ad Metadata
The Ad Metadata (if applicable) should be passed for each individual ad.
Keys | Description | Values | Required |
---|---|---|---|
type | type of Ad | 'preroll' , 'midroll' , 'postroll' 'ad' - If specific type can not be identified. |
✓ |
assetid | unique ID assigned to Ad | custom | ✓ |
Example Ad Object
var adMetadataObject =
{
type: 'preroll',
assetid: 'AD-1'
};
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.
Call Nielsen APIs
The method for calling events is ggPM().
nSdkInstance.ggPM('event', parameter, ...);
Interrupt Scenarios
Pause Event
The setPlayheadPostion event is used for handling pause. To indicate pause, stop passing the playhead position to the SDK. Once the content resumes, begin sending the playhead again with the correct playhead value.
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
- Network Loss
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).
window.addEventListener('beforeunload', function(event)
{
// Only inside a midroll indicate <stop> for the ad
nSdkInstance.ggPM('stop', playheadPosition);
// Indicate <end> and <stop> for the content
nSdkInstance.ggPM('end', playheadPosition);
nSdkInstance.ggPM('stop', playheadPosition);
});
Note: User may need to add code to support specific browser versions (e.g. older versions of Internet Explorer).
SDK Events
Event | Parameter | Description |
---|---|---|
'loadMetadata' | content/ad metadata object | Needs to be called at the beginning of each asset |
'setPlayheadPosition' | playhead position as integer VOD: || current position in seconds |
Pass playhead position every second during playback |
'stop' | playhead position in seconds | Call when content or ads complete playing and pass playhead position |
'end' | playhead position in seconds | Call when the current video asset completes playback and pass the playhead position. Example: At the end of the content stream, if the user switches to another piece of content, when the browser is refreshed or closed. |
SDK Playhead Event Sequence
The sample event lifecycles can be used as a reference for identifying the order for calling events.
Content Playback
// START OF STREAM
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);
// CONTENT PLAYS
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
//
// pass playhead every second
//
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
// END OF STREAM
nSdkInstance.ggPM('end', playheadPosition);
Content Playback with Ads
// START OF STREAM
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);
// PREROLL
nSdkInstance.ggPM('loadMetadata', prerollMetadataObject);
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
//
// pass playhead every second
//
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
nSdkInstance.ggPM('stop', playheadPosition);
// CONTENT
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
//
// pass playhead every second
//
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
nSdkInstance.ggPM('stop', playheadPosition);
// MIDROLL
nSdkInstance.ggPM('loadMetadata', midrollMetadataObject);
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
//
// pass playhead every second
//
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
nSdkInstance.ggPM('stop', playheadPosition);
// CONTENT RESUMES
nSdkInstance.ggPM('loadMetadata', contentMetadataObject);
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
//
// pass playhead every second
//
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
// END OF STREAM
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
nSdkInstance.ggPM('end', playheadPosition);
// POSTROLL
nSdkInstance.ggPM('loadmetadata', postrollMetadataObject);
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
//
// pass playhead every second
//
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
nSdkInstance.ggPM('stop', playheadPosition);
- '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'.
- For Ad Pods, 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.
Privacy and Opt-Out
There are two primary methods for implementing user Opt-out preferences:
- User Opt Out - Provide a link to the Nielsen Privacy Policy page when a User can make their selection
- Initialization Opt Out - Global OptOut Parameter
User 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 User Opt-Out option, include the following two items in your privacy policy.
- A notice that the player (or page in relation to static measurement) includes proprietary measurement software that allows users to contribute to market research (such as Nielsen Content Ratings).
- A link to the Nielsen Digital Measurement Privacy Policy at https://www.nielsen.com/th/en/legal/privacy-statement/digital-measurement/
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.
- Once users have opted out via this link, their browser cookies will contain the value TOTAL_OPTOUT. This will prevent a redirect to our data provider from occurring
- Users can opt back in via this link. When a user selects that link, their opt-out cookie will be deleted and they will be able to be measured moving forward.
The following paragraph is a template for a Privacy Statement.
The properties may feature Nielsen proprietary measurement software, which will allow users to contribute to market research, such as Nielsen Digital Content 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/th/en/legal/privacy-statement/digital-measurement/
User 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.
Initialization Opt Out
The BSDK600 now supports the ability to optout on initialization of the SDK by allowing an optout global parameter to be passed. This optout will be maintained through the session of the SDK instance. Specifications and limitations are specified below.
Type | Supported Values | Notes | Optout |
---|---|---|---|
optout | True, Yes, or 1 | Case is insensitive and can be string or bool
Example: nlsQ("XXXXXXXX-BH45-JKY6-BKH7-67GJKY68GJK7", "myInstance", { optout: true}); |
Ping parameter will set uoo=true. |
optout | False, No, or 0 | Case is insensitive and can be string or bool
Example: nlsQ("XXXXXXXX-BH45-JKY6-BKH7-67GJKY68GJK7", "myInstance", { optout: false}); |
Ping parameter will set uoo to blank. |
Example of using OptOut
var nSdkInstance = NOLBUNDLE.nlsQ("XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX", "nlsnInstance", {
nol_sdkDebug: "debug",
optout: "true"
});
Opt Out Overview
Browser Cookie | uoo value in session ping | Final Optout Status |
---|---|---|
Default Value | no uoo value or uoo=0 | Not Opted Out |
Default Value | uoo=1 | Opted Out |
Going Live
After the integration has been certified, users will need to make a couple of updates to the initialization call to ensure that player will be measured properly. Ensure that a production apid (starting with 'P') is used after going live. Disable debug logging by deleting {nol_sdkDebug: 'DEBUG'} from initialization call.
Example Production Initialization Call
var nSdkInstance = NOLBUNDLE.nlsQ("PXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX", "nlsnInstance", { optout: "false"});