Difference between revisions of "DCR Video Browser Bundled SDK"

From Engineering Client Portal

(Created page with "{{Breadcrumb|}} {{Breadcrumb|Digital}} {{Breadcrumb|DCR & DTVR}} {{CurrentBreadcrumb}} Category:Digital == Overview == The Nielsen SDK is one of multiple framework SDKs t...")
 
 
(3 intermediate revisions by one other user not shown)
Line 49: Line 49:
 
=== Add Static Queue Snippet ===
 
=== Add Static Queue Snippet ===
 
Add the following script tag to the website:
 
Add the following script tag to the website:
<syntaxhighlight lang="javascript"><script type="text/javascript">
+
<syntaxhighlight lang="javascript">
        /***************** Static Queue Snippet *********************/
+
<script type = "text/javascript" >
! function(t, n) {
+
  /***************** Static Queue Snippet *********************/
            t[n] = t[n] || {
+
  ! function(t, n) {
                nlsQ: function(e, c, o, r, s, i) {
+
    t[n] = t[n] || {
                    return s = t.document,
+
      nlsQ: function(e, c, o, r, s, i) {
                        r = s.createElement("script"),
+
        return s = t.document,
                        r.async = 1,
+
          r = s.createElement("script"),
                        r.src = ("http:" === t.location.protocol ? "http:" : "https:") + "//cdn-gl.imrworldwide.com/conf/" + e + ".js#name=" + c + "&ns=" + n, i = s.getElementsByTagName("script")[0], i.parentNode.insertBefore(r, i),
+
          r.async = 1,
                        t[n][c] = t[n][c] || {
+
          r.src = ("http:" === t.location.protocol ? "http:" : "https:") + "//cdn-gl.imrworldwide.com/conf/" + e + ".js#name=" + c + "&ns=" + n, i = s.getElementsByTagName("script")[0], i.parentNode.insertBefore(r, i),
                            g: o || {},
+
          t[n][c] = t[n][c] || {
                            ggPM: function(e, o, r, s, i) {
+
            g: o || {},
                                (t[n][c].q = t[n][c].q || []).push([e, o, r, s, i])
+
            ggPM: function(e, o, r, s, i) {
                            },
+
              (t[n][c].q = t[n][c].q || []).push([e, o, r, s, i])
                            trackEvent: function(e) {
+
            },
                                (t[n][c].te = t[n][c].te || []).push(e)
+
            trackEvent: function(e) {
                            }
+
              (t[n][c].te = t[n][c].te || []).push(e)
                        }, t[n][c] }}
+
            }
            } (window,"NOLBUNDLE");
+
          }, t[n][c]
</script></syntaxhighlight>
+
      }
 +
    }
 +
  }(window, "NOLBUNDLE");  
 +
</script>
 +
</syntaxhighlight>
  
 
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.
 
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 ===
+
===Create SDK Instance===
 
To initialize the SDK, create an SDK instance by making the initialization call:
 
To initialize the SDK, create an SDK instance by making the initialization call:
  
'''Initialization API Call'''
+
==== Initialization API Call ====
<syntaxhighlight lang="javascript">NOLBUNDLE.nlsQ("<apid>", "<instanceName>",{nol_sdkDebug: "debug"})</syntaxhighlight>
+
<syntaxhighlight lang="javascript">
 
+
NOLBUNDLE.nlsQ("<apid>", "<instanceName>",{nol_sdkDebug: "debug", optout: "false"})
When creating an instance, pass the following three variables:
+
</syntaxhighlight>
 +
<br>
 +
When creating an instance, pass the following values: (<code>nol_sdkDebug</code> and <code>optout</code> are optional)
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Parameter !! Description !! Values
+
! Parameter !! Description !! Values
 
|-
 
|-
| apid || Unique ID assigned to player/site. || <code>PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX</code>
+
| apid || Unique ID assigned to player/site || 'PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
 
|-
 
|-
| instanceName || Name of SDK instance || Any string value
+
|instanceName || Name of SDK instance || "any string value"
 
|-
 
|-
| nol_sdkDebug: "debug" || Enables Nielsen console logging. Only required for testing || <code>{nol_sdkDebug: "debug"}</code>
+
| nol_sdkDebug || Enables Nielsen console logging. Only required for testing || "{nol_sdkDebug: "debug"})"
 +
|-
 +
|optout || OptOut global parameter (Optional Parameter) || <code>1/0</code> or <code>true/false</code>
 
|}
 
|}
  
'''Example SDK Initialization'''
+
==== Example SDK Initialization ====
<syntaxhighlight lang="javascript">var nSdkInstance = NOLBUNDLE.nlsQ("XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX", "nlsnInstance", {nol_sdkDebug: "debug"});</syntaxhighlight>
+
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.
  
When the initialization call is made, a unique static configuration file, <code><apid>.js</code>, 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”.
  
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 [[DCR Video Browser Bundled SDK#Privacy_and_Opt-Out|Privacy and Opt-Out.]]
  
'''Example SDK Configuration'''
+
=== 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:
 
The configuration should include the Static Queue Snippet and an SDK Instance for an unique App ID as shown in the example:
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">
<script type="text/javascript">
+
<script type = "text/javascript" >
   /***************** Static Queue Snippet *********************/  
+
   /***************** Static Queue Snippet *********************/
 
   ! function(t, n) {
 
   ! function(t, n) {
 
     t[n] = t[n] || {
 
     t[n] = t[n] || {
Line 112: Line 120:
 
           t[n][c] = t[n][c] || {
 
           t[n][c] = t[n][c] || {
 
             g: o || {},
 
             g: o || {},
             ggPM: function(e, o, r, s, i) {(t[n][c].q = t[n][c].q || []).push([e, o, r, s, i])},
+
             ggPM: function(e, o, r, s, i) {
             trackEvent: function(e) {(t[n][c].te = t[n][c].te || []).push(e)}
+
              (t[n][c].q = t[n][c].q || []).push([e, o, r, s, i])
           }, t[n][c]     }   } }
+
            },
(window, "NOLBUNDLE");
+
             trackEvent: function(e) {
 +
              (t[n][c].te = t[n][c].te || []).push(e)
 +
            }
 +
           }, t[n][c]
 +
      }
 +
    }
 +
  }(window, "NOLBUNDLE");  
  
 
   // Created SDK Instance
 
   // Created SDK Instance
  var nSdkInstance = NOLBUNDLE.nlsQ("XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX","nlsnInstance", {nol_sdkDebug: "debug"});
+
var nSdkInstance = NOLBUNDLE.nlsQ("XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX", "nlsnInstance", {
 +
  nol_sdkDebug: "debug",
 +
  optout: "false"
 +
});
 
</script></syntaxhighlight>
 
</script></syntaxhighlight>
  
Line 267: Line 284:
 
<td> '''length''' </td>
 
<td> '''length''' </td>
 
<td> length of content in seconds </td>
 
<td> length of content in seconds </td>
<td> <code>seconds</code> (86400 for live stream) </td>
+
<td> <code>seconds</code> (0 for live stream) </td>
 
<td> Yes
 
<td> Yes
 
</td></tr>
 
</td></tr>
Line 322: Line 339:
 
<td> standard episode ID </td>
 
<td> standard episode ID </td>
 
<td> custom </td>
 
<td> custom </td>
<td>
+
<td> Yes
 
</td></tr>
 
</td></tr>
 
<tr>
 
<tr>
Line 620: Line 637:
 
<td> '''length''' </td>
 
<td> '''length''' </td>
 
<td> length of content in seconds </td>
 
<td> length of content in seconds </td>
<td> <code>seconds</code> (86400 for live stream) </td>
+
<td> <code>seconds</code> (0 for live stream) </td>
 
<td> Yes
 
<td> Yes
 
</td></tr>
 
</td></tr>
Line 670: Line 687:
 
   "content":{
 
   "content":{
 
     "type":"content",
 
     "type":"content",
     "length":"86400",
+
     "length":"0",
 
     "adModel":"1",
 
     "adModel":"1",
 
     "adloadtype":"1"},
 
     "adloadtype":"1"},
Line 732: Line 749:
  
  
== Opt-Out ==
+
{{Template:Browser_Privacy_and_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 http://priv-policy.imrworldwide.com/priv/browser/us/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, 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 http://priv-policy.imrworldwide.com/priv/browser/us/en/optout.html.
+
== 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.
 +
Disable debug logging by deleting {nol_sdkDebug: 'DEBUG'} from initialization call.
 +
Example Production Initialization Call
  
=== Opt Back In ===
+
<syntaxhighlight lang="javascript">
 
+
var nSdkInstance = NOLBUNDLE.nlsQ("XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX", "nlsnInstance", { optout: "false"});
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.
+
</syntaxhighlight>
 
 
== Going Live ==
 
Once the DCR Tracking Code is added to Instant Articles, Nielsen will validate the implementation. Following Nielsen testing, users need to make a couple of updates to the initialization call to ensure that the site is being measured properly.
 
# '''App ID''': Ensure that correct <apid> is used during initialization<syntaxhighlight lang="javascript">'PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'</syntaxhighlight>
 
# '''Debug Logging''': Disable logging by deleting <code>{nol_sdkDebug: 'DEBUG'}</code> from initialization call.
 
#* '''Example Production Initialization Call''' - Refer to the production initialization call below:<syntaxhighlight lang="javascript">var nSdkInstance = NOLBUNDLE.nlsQ("PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "nlsnInstance");</syntaxhighlight>
 
  
 
== Sample Code ==
 
== Sample Code ==
 
This code is for example purposes only to demonstrate a very simple video implementation, with a single preroll and single content block.
 
This code is for example purposes only to demonstrate a very simple video implementation, with a single preroll and single content block.
 
<syntaxhighlight lang=javascript>
 
<syntaxhighlight lang=javascript>
<script>
+
<script >
// Setup videojs sample player
+
  // Setup videojs sample player
var nielsenid = document.getElementById("my-sdkplayer");
+
  var nielsenid = document.getElementById("my-sdkplayer");
 
var coolPlayer = videojs('my-sdkplayer', {
 
var coolPlayer = videojs('my-sdkplayer', {
    controls: true,
+
  controls: true,
    autoplay: true,
+
  autoplay: true,
    preload: 'auto',
+
  preload: 'auto',
 
});
 
});
 
var prevPos = null;
 
var prevPos = null;
  
 
coolPlayer.preroll({
 
coolPlayer.preroll({
    src: {
+
  src: {
        src: "assets/CleaningCrew.mp4",
+
    src: "assets/CleaningCrew.mp4",
        type: "video/mp4"
+
    type: "video/mp4"
    },
+
  },
    href: "http://videojs.com",
+
  href: "http://videojs.com",
    adsOptions: {
+
  adsOptions: {
        debug: true
+
    debug: true
    }
+
  }
 
});
 
});
  
 
videojs('my-sdkplayer').ready(function() {
 
videojs('my-sdkplayer').ready(function() {
    // EXAMPLE: Start playing the video.
+
  // EXAMPLE: Start playing the video.
  
    coolPlayer.play();
+
  coolPlayer.play();
    var obj = {
+
  var obj = {
        event: 'playhead', // playhead,pause,complete,adstop
+
    event: 'playhead', // playhead,pause,complete,adstop
 +
    type: 'content',
 +
    playheadPosition: '0',
 +
    metadata: {
 +
      content: {
 
         type: 'content',
 
         type: 'content',
         playheadPosition: '0',
+
         assetid: 'VID98-2B88',
        metadata: {
+
        program: 'Put a programname here ',
            content: {
+
        section: 'section name here'
                type: 'content',
+
        title: 'S01E02',
                assetid: 'VID98-2B88',
+
        length: '180',
                program: 'Put a programname here ',
+
        airdate: '20190101 10:01:00',
                section: 'section name here'
+
        isfullepisode: 'y',
                title: 'S01E02',
+
        crossId1: 'Standard Episode ID',
                length: '180',
+
        crossID2: 'Content Originator',
                airdate: '20190101 10:01:00',
+
        adloadtype: '2'
                isfullepisode: 'y',
+
      },
                crossId1: 'Standard Episode ID',
+
      ad: {},
                crossID2: 'Content Originator',
+
      static: {}
                adloadtype: '2'
+
    }
            },
+
  };
            ad: {},
 
            static: {}
 
        }
 
    };
 
  
    coolPlayer.on('timeupdate', function() {
+
  coolPlayer.on('timeupdate', function() {
        var getcurrentTime = coolPlayer.currentTime();
+
    var getcurrentTime = coolPlayer.currentTime();
        var intPlayedTime = parseInt(getcurrentTime, 10);
+
    var intPlayedTime = parseInt(getcurrentTime, 10);
        if (intPlayedTime > 0 && intPlayedTime !== prevPos) {
+
    if (intPlayedTime > 0 && intPlayedTime !== prevPos) {
            // check for playhead change so it's only called once per second  
+
      // check for playhead change so it's only called once per second  
            console.log('PLAYHEAD EVENT **************************************************************');
+
      console.log('PLAYHEAD EVENT **************************************************************');
            obj.event = 'playhead';
+
      obj.event = 'playhead';
            obj.type = 'content';
+
      obj.type = 'content';
            obj.metadata.ad = {};
+
      obj.metadata.ad = {};
            prevPos = intPlayedTime;
+
      prevPos = intPlayedTime;
            obj.playheadPosition = Math.round(getcurrentTime);
+
      obj.playheadPosition = Math.round(getcurrentTime);
            nSdkInstance.trackEvent(obj);
+
      nSdkInstance.trackEvent(obj);
        }
+
    }
    });
+
  });
  
    this.on('adstart', function() {
+
  this.on('adstart', function() {
        console.log('ADSTART EVENT **************************************************************');
+
    console.log('ADSTART EVENT **************************************************************');
        obj.type = 'ad';
+
    obj.type = 'ad';
        obj.metadata.ad = {
+
    obj.metadata.ad = {
            type: 'preroll',
+
      type: 'preroll',
            assetid: 'AD9455',
+
      assetid: 'AD9455',
            adldx: '1',
+
      adldx: '1',
            program: 'Cant Skip Campaign',
+
      program: 'Cant Skip Campaign',
            title: 'Cleaning Crew',
+
      title: 'Cleaning Crew',
            length: '36',
+
      length: '36',
        };
+
    };
        nSdkInstance.trackEvent(obj);
+
    nSdkInstance.trackEvent(obj);
    });
+
  });
  
    this.on('contentresumed', function() {
+
  this.on('contentresumed', function() {
        console.log('CONTENT RESUMED EVENT **************************************************************');
+
    console.log('CONTENT RESUMED EVENT **************************************************************');
        obj.type = 'content';
+
    obj.type = 'content';
        obj.event = 'playhead';
+
    obj.event = 'playhead';
        obj.metadata.ad = {};
+
    obj.metadata.ad = {};
        nSdkInstance.trackEvent(obj);
+
    nSdkInstance.trackEvent(obj);
    });
+
  });
  
    this.on('pause', function() {
+
  this.on('pause', function() {
        console.log('PAUSE EVENT **************************************************************');
+
    console.log('PAUSE EVENT **************************************************************');
        obj.event = 'pause';
+
    obj.event = 'pause';
        obj.playheadPosition = Math.round(coolPlayer.currentTime());
+
    obj.playheadPosition = Math.round(coolPlayer.currentTime());
        nSdkInstance.trackEvent(obj);
+
    nSdkInstance.trackEvent(obj);
    });
+
  });
  
    this.on('adtimeupdate', function() {
+
  this.on('adtimeupdate', function() {
        var getcurrentTime = coolPlayer.currentTime();
+
    var getcurrentTime = coolPlayer.currentTime();
        var intPlayedTime = parseInt(getcurrentTime, 10);
+
    var intPlayedTime = parseInt(getcurrentTime, 10);
        if (intPlayedTime > 0 && intPlayedTime !== prevPos) {
+
    if (intPlayedTime > 0 && intPlayedTime !== prevPos) {
            // check for playhead change so it's only called once per second  
+
      // check for playhead change so it's only called once per second  
            console.log('AD PLAYHEAD EVENT **************************************************************');
+
      console.log('AD PLAYHEAD EVENT **************************************************************');
            console.log(Math.round(getcurrentTime));
+
      console.log(Math.round(getcurrentTime));
            prevPos = intPlayedTime;
+
      prevPos = intPlayedTime;
            obj.playheadPosition = Math.round(getcurrentTime);
+
      obj.playheadPosition = Math.round(getcurrentTime);
            nSdkInstance.trackEvent(obj);
+
      nSdkInstance.trackEvent(obj);
        };
+
    };
    });
+
  });
  
    this.on('adend', function() {
+
  this.on('adend', function() {
        console.log('AD STOP EVENT **************************************************************');
+
    console.log('AD STOP EVENT **************************************************************');
        obj.event = 'adstop';
+
    obj.event = 'adstop';
        nSdkInstance.trackEvent(obj);
+
    nSdkInstance.trackEvent(obj);
    });
+
  });
  
    this.on('ended', function() {
+
  this.on('ended', function() {
        console.log('COMPLETE EVENT **************************************************************');
+
    console.log('COMPLETE EVENT **************************************************************');
        obj.event = 'complete';
+
    obj.event = 'complete';
        nSdkInstance.trackEvent(obj);
+
    nSdkInstance.trackEvent(obj);
    });
+
  });
 
});
 
});
  
                </script>
+
</script>
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 21:10, 29 May 2019

Engineering Portal breadcrumbArrow.png Digital breadcrumbArrow.png DCR & DTVR breadcrumbArrow.png DCR Video Browser Bundled SDK

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 App SDK is the framework for mobile application developers to integrate Nielsen Measurement into their media player applications. 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 an application like:

  • Application launch events and how long app was running
  • Time of viewing a sub section / page in the application.

Prerequisites

To start using the Simplified SDK for Browser, you will need an Appid. This is a Unique ID assigned to the player/site and configured by product. If you do not have an AppID , please contact our SDK sales support team. Refer to Digital Measurement Onboarding guide for information on how to get a Nielsen App SDK and appid.

Simplified SDK API

As part of making the SDK more user friendly and reduce the number of app integration touch points, Nielsen has designed a simple interface to pass metadata to the sdk while reducing the number of API calls. The new trackevent() API has been implemented as a wrapper for the existing SDK and will be responsible for handling new API calls, performing validation, and translation of new API calls to the existing Nielsen App SDK API methods. Applications which are already integrated with the existing SDK API, are unaffected by this new API. SimplifiedAPI vs StandardAPI New.jpg Click here to zoom in on image

Manages the order of metadata (ad vs content and playheads)

Existing API has a number of methods used for reporting player and application state changes to the SDK. Order of calls is important for the SDK in the existing API. In the new enhanced API all these calls will be replaced with one API call that will get one dictionary object with many key-value pairs, where any value could be another complex dictionary object. All the data provided in the existing API in separate calls will be provided in one single call. SDK will analyse the data received in the dictionary object, compare it with the data received previously and generate a sequence of calls for the existing API.

Everything passed via trackevent()

The New API method supports the following event types:

Key Description
playhead

It is used to pass content, ad or static metadata, the current playhead value, UNIX timestamp or id3 payload, ott information to the SDK.

pause

This event should be passed when the content playback is paused.

complete

It is called when session is completed or ends.

adStop

Should be called at the end of each ad. This event type is required to handle the case when advertisements could not be distinguished, as its assetId is the same.

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.

'PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'

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" >
  /***************** Static Queue Snippet *********************/
  ! function(t, n) {
    t[n] = t[n] || {
      nlsQ: function(e, c, o, 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=" + c + "&ns=" + n, i = s.getElementsByTagName("script")[0], i.parentNode.insertBefore(r, i),
          t[n][c] = t[n][c] || {
            g: o || {},
            ggPM: function(e, o, r, s, i) {
              (t[n][c].q = t[n][c].q || []).push([e, o, r, s, i])
            },
            trackEvent: function(e) {
              (t[n][c].te = t[n][c].te || []).push(e)
            }
          }, t[n][c]
      }
    }
  }(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", optout: "false"})


When creating an instance, pass the following values: (nol_sdkDebug and optout are optional)

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 "{nol_sdkDebug: "debug"})"
optout OptOut global parameter (Optional 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.

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" >
  /***************** Static Queue Snippet *********************/
  ! function(t, n) {
    t[n] = t[n] || {
      nlsQ: function(e, c, o, 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=" + c + "&ns=" + n, i = s.getElementsByTagName("script")[0], i.parentNode.insertBefore(r, i),
          t[n][c] = t[n][c] || {
            g: o || {},
            ggPM: function(e, o, r, s, i) {
              (t[n][c].q = t[n][c].q || []).push([e, o, r, s, i])
            },
            trackEvent: function(e) {
              (t[n][c].te = t[n][c].te || []).push(e)
            }
          }, t[n][c]
      }
    }
  }(window, "NOLBUNDLE"); 

  // Created SDK Instance
var nSdkInstance = NOLBUNDLE.nlsQ("XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX", "nlsnInstance", {
  nol_sdkDebug: "debug",
  optout: "false"
});
</script>

Simplified API Syntax

The existing API has a number of methods used for reporting player and application state changes to the SDK. The order of calls is important for the SDK in the existing API. In the new simplified API, all these calls will be replaced with one API call that will get one dictionary object with many key-value pairs, where any value could be another complex dictionary object. All the data provided in the older API in separate calls will be provided in one single call.

Main API call for the new NielsenEventTracker API:

 nSdkInstance.trackEvent({metadata})

Handling JSON Metadata

Parameter “data” is a JSON object with many key-value pairs that holds all information required by SDK.

Format of input object is the following:

{ 
 "event": <event identifier>,
 "type": <type of metadata>,
 "metadata":{ 
   "content": <content metadata object>,
   "ad": <ad metadata object>,
   "static": <static metadata object>
 },
 "playheadPosition":<playhead value | UNIX timestamp (seconds since Jan-1-1970 UTC) >,
 "id3Data": <id3 payload>,
}


Event Types

The New API method supports the following event types:

Key Description
playhead

It is used to pass content, ad or static metadata, the current playhead value, Unix timestamp or id3 payload, ott information to the SDK.

pause

This event should be used when content playback is paused.
(Pause is detected by SDK automatically when the time gap between commands is more than 30 minutes.)

complete

It is called when session is completed or ends.

adStop

Should be called at the end of each ad. This event type is required to handle the case when advertisements could not be distinguished, as its assetId is the same.


DCR and DTVR require various levels of data. Please select the TAB of the product you are interested in reviewing.

DCR

Digital Content Ratings

Parameter Description Supported values Example
event Event identifier

String: playhead,pause,complete, adStop

"event":"playhead"
type Determines the metadata object

that should be used for crediting.

String:
content, ad, static

"type":"content"
metadata Object that holds metadata values of specific types

Detailed in tables below

Object
"metadata":{ 
   "content": <content metadata object>,
   "ad": <ad metadata object>,
   "static": <static metadata object>
 },
playheadPosition Playhead value in seconds or Unix timestamp String

Position value is Unix timestamp: "playheadPosition":"1543437655"

Position value is playhead:

"playheadPosition":"10"

Content Metadata

Content metadata sent for every playheadposition update.

Keys Description Example Required
assetName name of program (100 character limit) "MyTest789" Yes
assetid unique ID assigned to asset custom Yes
length length of content in seconds seconds (0 for live stream) Yes
program name of program (100 character limit) custom Yes
segB custom segment B + custom
segC custom segment C + custom
title name of program (100 character limit) custom Yes
type 'content', 'ad', 'static' 'content' Yes
section Unique Value assigned to page/site section HomePage Yes
airdate the airdate in the linear TV ++ YYYYMMDD HH24:MI:SS Yes
isfullepisode full episode flag "y"- full episode, "n"- non full episode Yes
crossId1 standard episode ID custom Yes
crossId2 content originator (only required for distributors) Nielsen provided
adloadtype linear vs dynamic ad model 1=Linear

2=Dynamic Ads

custom

+ Custom segments (segB and segC) can be used to aggregate video and/or static content within a single Brand to receive more granular reports within a brand.
++ Acceptable Air Date Formats:

YYYYMMDD HH24:MI:SS
YYYYMMDDHH24MISS
YYYY-MM-DDTHH:MI:SS
YYYY-MM-DDHH:MI:SS 
YYYYMMDDHH:MI:SS
MM-DD-YYYY
YYYYMMDD HH:MI:SS


For USA all times should be EST, for all other countries Local Time. Below is a sample event for DCR. If no ad or static values, these can be left as blank/null.

{ 
"event": "playhead",
"type": "content",
"metadata": { 
  "content":{
    "assetName":"Big Buck Bunny",
    "assetid":"B66473",
    "length":"3600",
    "program":"MyProgram",
    "segB":"CustomSegmentValueB",
    "segC":"segmentC",
    "title":"S2,E3",
    "type":"content",
    "section":"cloudApi_app",
    "airdate":"20180120 10:00:00",
    "isfullepisode":"y",
    "crossId1":"Standard Episode ID",
    "crossId2" :"Content Originator",
    "adloadtype":"2"},
"ad": {},
"static": {}
},
"playheadPosition": "",
}

DTVR

Digital TV Ratings info

Parameter Description Supported values Example
event Event identifier

String: playhead,pause,complete, adStop

"event":"playhead"
type Determines the metadata object that should be used for crediting.

String:
content, ad, static

"type":"content"
adModel linear vs dynamic ad model 1=Linear

2=Dynamic Ads

custom
channelName Any string representing the.channel/stream Object custom
playheadPosition Playhead value in seconds or Unix timestamp String

Position value is Unix timestamp: "playheadPosition":"1543437655"

Position value is playhead:

"playheadPosition":"10"

id3Data Nielsen ID3 payload string Object

id3Data: www.nielsen.com/065H2g6E7ZyQ5UdmMAbbpg ==/_EMc37zfVgq_8KB7baUYfg==/ADQCAmgV1Xyvnynyg60 kZO_Ejkcn2KLSrTzyJpZZ-QeRn8GpMGTWI7-HrEKzghxyzC yBEoIDv2kA2g1QJmeYOl5GnwfrLDVK2bNLTbQxr1z9VBfxa hBcQP5tqbjhyMzdVqrMKuvvJO1jhtSXa9AroChb11ZUnG1W VJx2O4M=/33648/22847/00

Below is a sample event for DTVR. If no ad or static values, these can be left as blank/null.

{ 
"event": "playhead",
"type": "content",
"metadata": { 
  "content":{
    "adModel":"1",
    "channelname":"channel1"
  },
"ad": {},
"static": {}
},
"playheadPosition": "",
"id3Data": "www.nielsen.com/065H2g6E7ZyQ5UdmMAbbpg==/_
EMc37zfVgq_8KB7baUYfg==/ADQCAmgV1Xyvnynyg60kZO_Ejkcn
2KLSrTzyJpZZ-QeRn8GpMGTWI7-HrEKzghxyzCyBEoIDv2kA2g1Q
JmeYOl5GnwfrLDVK2bNLTbQxr1z9VBfxahBcQP5tqbjhyMzdVqrMK
uvvJO1jhtSXa9AroChb11ZUnG1WVJx2O4M=/33648/22847/00"
}

DCR & DTVR

Applies to DCR and DTVR

Parameter Description Supported values Example
event Event identifier

String: playhead, pause, complete, adStop

"event":"playhead"
type Determines the metadata object that should be used for crediting.

String:
content, ad, static

"type":"content"
metadata Object that holds metadata values of specific types

Detailed in tables below

Object
"metadata":{ 
   "content": <content metadata object>,
   "ad": <ad metadata object>,
   "static": <static metadata object>
 },
playheadPosition Playhead value in seconds or Unix timestamp String

Position value is Unix timestamp: "playheadPosition":"1543437655"

Position value is playhead:

"playheadPosition":"10"

id3Data Nielsen ID3 payload string Object

id3Data: www.nielsen.com/065H2g6E7ZyQ5UdmMAbbpg ==/_EMc37zfVgq_8KB7baUYfg==/ADQCAmgV1Xyvnynyg60 kZO_Ejkcn2KLSrTzyJpZZ-QeRn8GpMGTWI7-HrEKzghxyzC yBEoIDv2kA2g1QJmeYOl5GnwfrLDVK2bNLTbQxr1z9VBfxa hBcQP5tqbjhyMzdVqrMKuvvJO1jhtSXa9AroChb11ZUnG1W VJx2O4M=/33648/22847/00

ottData Object that holds ott information Object
ottData:{
ottStatus:1,
ottType:casting,
ottDevice:chromecast,
ottDeviceName:Google ChromeCast,
ottDeviceID:1234,
ottDeviceModel:ChromeCast,
ottDeviceVersion:1.0.0
}

Content Metadata

Content metadata sent for every playheadposition update.

Keys Description Example Required
length length of content in seconds seconds (0 for live stream) Yes
type 'content', 'ad', 'static' 'content' Yes
adModel linear vs dynamic ad model 1=Linear

2=Dynamic Ads

custom
adloadtype DCR Ad Model 1=Linear

2=Dynamic Ads

custom

+ Custom segments (segB and segC) can be used to aggregate video and/or static content within a single Brand to receive more granular reports within a brand.
++ Acceptable Air Date Formats:

YYYYMMDD HH24:MI:SS
YYYYMMDDHH24MISS
YYYY-MM-DDTHH:MI:SS
YYYY-MM-DDHH:MI:SS 
YYYYMMDDHH:MI:SS
MM-DD-YYYY
YYYYMMDD HH:MI:SS


Below is a sample event for DCR/DTVR joint integration. If no ad or static values, these can be left as blank/null.

{ 
"event": "playhead",
"type": "content",
"metadata": { 
  "content":{
    "type":"content",
    "length":"0",
    "adModel":"1",
    "adloadtype":"1"},
  "ad": {},
  "static": {}
},
"playheadPosition": "",
"id3Data": "www.nielsen.com/065H2g6E7ZyQ5UdmMAbbpg==/_
EMc37zfVgq_8KB7baUYfg==/ADQCAmgV1Xyvnynyg60kZO_Ejkcn
2KLSrTzyJpZZ-QeRn8GpMGTWI7-HrEKzghxyzCyBEoIDv2kA2g1Q
JmeYOl5GnwfrLDVK2bNLTbQxr1z9VBfxahBcQP5tqbjhyMzdVqrMK
uvvJO1jhtSXa9AroChb11ZUnG1WVJx2O4M=/33648/22847/00"
}

Ad Metadata

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

Keys Description Values Example
assetid unique ID assigned to ad custom
(no Special Characters)
'AD1234'
title unique name assigned to ad custom 'ADtitle'
adldx Ad Index (*See Note below*) custom "66478364"
type type of ad 'preroll', 'midroll', or 'postroll' 'preroll'
length length of ad In Seconds '20'

Ad Metadata Sample

{
  "ad": {
    "assetid":"AD12345",
    "title":"ADTestTitle",
    "adldx":"1",
    "type":"preroll",
    "length":"20"
  },
}

Managing Ads

If there is an Ad block within the playing content (such as a midroll) you need to:

  • Reset the playhead position to 0 for each ad.
  • Call the adStop event at the end of each ad or increment the adldx

The Simplified SDK will can automatically detect the change from ad to content, or even ad to ad if the assetID changes; however, there could be situations where the same ad is played back to back. You can either increment/change the adldx value, and/or call adStop at the end of each Ad.

Sometimes it is not possible for integrators to provide different assetId value for individual ads in a sequence of ads. Taking this into account the Nielsen Simplified API will support a new parameter for ad metadata: adIdx. This parameter is just an index of an individual ad in a sequence of ads. Once the next ad is started the adIdx parameter should be changed and provided as part of ad metadata.

            // Example of passing both values
            self.data.updateValue("adStop", forKey: "event")
            self.data.updateValue("223", forKey: "adldx")
            self.nielsenEventTracker.trackEvent(data)


Privacy and Opt-Out

There are two primary methods for implementing user Opt-out preferences:

  1. User Opt Out - Provide a link to the Nielsen Privacy Policy page when a User can make their selection
  2. 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 TV Ratings).
  • A link to the Nielsen Digital Measurement Privacy Policy at https://www.nielsen.com/digitalprivacy

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 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/digitalprivacy

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
TOTAL_OPTOUT uoo=0 Opted Out
TOTAL_OPTOUT 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. Disable debug logging by deleting {nol_sdkDebug: 'DEBUG'} from initialization call. Example Production Initialization Call

var nSdkInstance = NOLBUNDLE.nlsQ("XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX", "nlsnInstance", { optout: "false"});

Sample Code

This code is for example purposes only to demonstrate a very simple video implementation, with a single preroll and single content block.

<script >
  // Setup videojs sample player
  var nielsenid = document.getElementById("my-sdkplayer");
var coolPlayer = videojs('my-sdkplayer', {
  controls: true,
  autoplay: true,
  preload: 'auto',
});
var prevPos = null;

coolPlayer.preroll({
  src: {
    src: "assets/CleaningCrew.mp4",
    type: "video/mp4"
  },
  href: "http://videojs.com",
  adsOptions: {
    debug: true
  }
});

videojs('my-sdkplayer').ready(function() {
  // EXAMPLE: Start playing the video.

  coolPlayer.play();
  var obj = {
    event: 'playhead', // playhead,pause,complete,adstop
    type: 'content',
    playheadPosition: '0',
    metadata: {
      content: {
        type: 'content',
        assetid: 'VID98-2B88',
        program: 'Put a programname here ',
        section: 'section name here'
        title: 'S01E02',
        length: '180',
        airdate: '20190101 10:01:00',
        isfullepisode: 'y',
        crossId1: 'Standard Episode ID',
        crossID2: 'Content Originator',
        adloadtype: '2'
      },
      ad: {},
      static: {}
    }
  };

  coolPlayer.on('timeupdate', function() {
    var getcurrentTime = coolPlayer.currentTime();
    var intPlayedTime = parseInt(getcurrentTime, 10);
    if (intPlayedTime > 0 && intPlayedTime !== prevPos) {
      // check for playhead change so it's only called once per second 
      console.log('PLAYHEAD EVENT **************************************************************');
      obj.event = 'playhead';
      obj.type = 'content';
      obj.metadata.ad = {};
      prevPos = intPlayedTime;
      obj.playheadPosition = Math.round(getcurrentTime);
      nSdkInstance.trackEvent(obj);
    }
  });

  this.on('adstart', function() {
    console.log('ADSTART EVENT **************************************************************');
    obj.type = 'ad';
    obj.metadata.ad = {
      type: 'preroll',
      assetid: 'AD9455',
      adldx: '1',
      program: 'Cant Skip Campaign',
      title: 'Cleaning Crew',
      length: '36',
    };
    nSdkInstance.trackEvent(obj);
  });

  this.on('contentresumed', function() {
    console.log('CONTENT RESUMED EVENT **************************************************************');
    obj.type = 'content';
    obj.event = 'playhead';
    obj.metadata.ad = {};
    nSdkInstance.trackEvent(obj);
  });

  this.on('pause', function() {
    console.log('PAUSE EVENT **************************************************************');
    obj.event = 'pause';
    obj.playheadPosition = Math.round(coolPlayer.currentTime());
    nSdkInstance.trackEvent(obj);
  });

  this.on('adtimeupdate', function() {
    var getcurrentTime = coolPlayer.currentTime();
    var intPlayedTime = parseInt(getcurrentTime, 10);
    if (intPlayedTime > 0 && intPlayedTime !== prevPos) {
      // check for playhead change so it's only called once per second 
      console.log('AD PLAYHEAD EVENT **************************************************************');
      console.log(Math.round(getcurrentTime));
      prevPos = intPlayedTime;
      obj.playheadPosition = Math.round(getcurrentTime);
      nSdkInstance.trackEvent(obj);
    };
  });

  this.on('adend', function() {
    console.log('AD STOP EVENT **************************************************************');
    obj.event = 'adstop';
    nSdkInstance.trackEvent(obj);
  });

  this.on('ended', function() {
    console.log('COMPLETE EVENT **************************************************************');
    obj.event = 'complete';
    nSdkInstance.trackEvent(obj);
  });
});

</script>