DCR Italy Video Browser SDK (6.0.0): Difference between revisions

From Engineering Client Portal

No edit summary
(added missing interrupt scenarios)
Line 268: Line 268:
   nSdkInstance.ggPM('end', endPlayheadPosition);  
   nSdkInstance.ggPM('end', endPlayheadPosition);  
</syntaxhighlight>
</syntaxhighlight>
== 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
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).
<syntaxhighlight lang="javascript">
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);
});
</syntaxhighlight>
<blockquote>'''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).</blockquote>





Revision as of 12:44, 14 November 2017

Engineering Portal / Digital / International / DCR Italy Video Browser SDK (6.0.0)

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), Digital Audio. 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.

Prerequisites

To get started, an App ID is needed. The App ID 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

Add Static Queue Snippet

Add the following script tag to the website:

<script type="text/javascript">
!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 API call:

Initialization API Call

NOLBUNDLE.nlsQ("<apid>", "<instanceName>",{nol_sdkDebug: "debug"})

When creating an instance, pass the following values:

Parameter Description Required Values
apid Unique ID assigned to player/site.
  • Test: begins with ‘T’ and is used for testing
  • Production: begins with ‘P’ and is used in live environment when testing and certification is completed
Yes 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
instanceName Name of SDK instance Yes "any string value"
nol_sdkDebug Enables Nielsen console logging. Only required for testing Optional 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.bundle.min.js”.

Example SDK Initialization API Call

 var nSdkInstance = NOLBUNDLE.nlsQ("P14273221-CF5C-46BF-A832-994AEFB73AA4","myPlayerName", {nol_sdkDebug: "DEBUG"});

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(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.

Key Description Values Required
type Type of asset "content"
assetid Unique ID assigned to content (max. 40 characters) custom
program Name of program (25 characters limit) custom
title Episode title (40 characters limit) custom
length Length of content in seconds for VOD (Video on demand). The value for live stream content is 86400
  • "seconds"– VOD
  • "86400"– Live Stream

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" YYYYMMDD hh:mm:ss
isfullepisode Full episode flag
  • "y"– full episode
  • "n"– non full episode

adloadtype type of ad load:
  • 1) Linear – matches TV ad load
  • 2) Dynamic – Dynamic Ad Insertion (DAI)
  • "1" – content with linear ads
  • "2" – content with dynamic ads

✓ (has to be "2" for DCR/Italy)

Example Content Object

Note: all parameters should be provided as strings (also length)

//create content object
var contentMetadataObject =
{  
  type:           'content',
  assetid:        'VID123-123456',
  program:        'program name',
  title:          'episode title',
  length:         '1020',    // length in seconds (String)
  airdate:        '19700101 00:00:00',
  isfullepisode:  'y',
  adloadtype:     '2'
};

Ad Metadata Object

The ad metadata should be passed for each individual ad, if ads are available during or before the stream (content) begins.

Keys Description Values Required
type type of ad 'preroll', 'midroll', or 'postroll'
assetid unique ID assigned to ad custom

Example Ad Object

//create pre-roll ad object
var prerollMetadataObject = 
{  
  assetid: 'AD-1',
  type:    'preroll'
};

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'
  • "VOD (or ad ): || current position in seconds (integer)
  • "Live: current UTC timestamp (seconds since January 1st 1970)

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

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);


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

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 or covering Safari on mobile browsers ... you may use "onpagehide" event as well).


SDK Event Lifecycle

The sample event lifecycle can be used as a reference for identifying the order for calling events.

Note

  • For Audiweb there is no need to tag ads in video stream ... please see 1st example how to use without ads!

without Ads


Event Lifecycle without ads:


even browser no ads.png

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:


event browser.png

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


Note: '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'.

Note : For Ad, events must be called for each individual Ad. Each Ad playhead position should begin at ‘0’ when ad starts.

Note: 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.

Note: 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.

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://priv-policy.imrworldwide.com/priv/browser/it/it/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.

  1. 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");