DCR Video Browser SDK: Difference between revisions

From Engineering Client Portal

No edit summary
(xx)
Line 3: Line 3:


== Prerequisites ==
== Prerequisites ==
To start using the Browser SDK, the following details are required:
<br />
* '''App ID (apid):''' Unique ID assigned to the player/site and configured by product.
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.
* '''sfcode:''' Unique identifier for the environment that the SDK should point to. During testing, please use the sfcode as "dcr-cert".
* '''ggCom.as (For Flash Player Porjects only):''' Nielsen ActionScript Library to compile within the Flash player project. Configure ggCom.as as mentioned in subsequent sections and include the edited file in the project.
If you do not have any of these pre-requisites or if you have any questions, please contact our SDK sales support team.


== Import Library ==
<syntaxhighlight lang="html">   
In the HTML head section of each page, call the Nielsen library using the script tag, as shown below.
       apid: "PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"     
<syntaxhighlight lang="html">  <script type="javascript" src="http://secure-dcr-cert.imrworldwide.com/novms/js/2/ggcmb510.js"></script></syntaxhighlight>
 
== Define GlobalParams ==
<syntaxhighlight lang="html">  <script type="javascript">
  var _nolggGlobalParams =
    {
      sfcode: "dcr-cert",
       apid: "TXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      apn: "test-setup",
      nsdkv: "511",
      nol_sdkdebug: "INFO"
    };
</script></syntaxhighlight>
For Flash integration, global parameters must be set as an object in ggCom.as, as follows.
<syntaxhighlight lang="javascript">  public var _nolggGlobalParams:Object =
  {
      apid: "TXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      sfcode: "dcr-cert",
      apn: "test-player",
      nol_sdkDebug: "DEBUG",
      nsdkv: "511"
   };
</syntaxhighlight>
</syntaxhighlight>


== Initialize SDK ==
== Configure SDK ==
Initialize Browser SDK as soon as the Parent / Main Page is loaded. During the initialization, custom parameters can be appended to the global parameter object. These custom (extended) parameters are optional. Use them only if the player application can handle the custom parameter data.
<br />
 
There are two steps required for configuring the SDK:
The Nielsen Browser SDK supports multiple processing instances. To create an instance, call the <code>getInstance()</code> function
<br/>
<syntaxhighlight lang="javascript">    var nSdkInstance=NOLCMB.getInstance(instanceName);</syntaxhighlight>
*Add Static Queue Snippet
All subsequent calls to getInstance with the same instanceName will return an already created SDK instance with that name. This will allow accessing the same object from different parts of the code.
*Create SDK Instance
 
<br/>
The "instanceName" parameter is optional and will be set to "default" if missing. To use a single default SDK instance, call
'''Static Queue Snippet'''
<syntaxhighlight lang="javascript">    var nSdkInstance=NOLCMB.getInstance();</syntaxhighlight>
<br/>
To instantiate Nielsen Browser SDK for '''Flash integration''', add the following line within the player setup.
Add the following script tag to the website:
<syntaxhighlight lang="javascript">    ggCom.getInstance(RootReference.stage.loaderInfo);</syntaxhighlight>
<br/>
In order to initialize the SDK, parameters must be passed when calling the initialization function (ggInitialize). The available parameters are listed in the table below.
<syntaxhighlight lang="javascript">  
{| class="wikitable"
<script>
|-
!function(t,n)
! Parameters !! Description !! Value !! Required? (Y/N)
{
|-
  t[n]=t[n]||
| apid || UniqueID assigned to player/site. There are two IDs provided for
  {
# Test: begins with ‘T’ and is used for testing, and
    nlsQ:function(e,o,c,r,s,i)
# Production: begins with ‘P’ and is used when testing is completed in live environment.
|| Nielsen assigned || Yes
|-
| apn || User-defined string value for describing the player/site || Client-specified || Yes
|-
| sfcode || Location of collection environment. During testing, all traffic should be directed to <code>dcr-cert</code>. || "dcr-cert" – testing
"dcr" – production || Yes
|-
| nsdkv || Nielsen SDK Version currently being used. || Nielsen assigned (‘511’ for Browser SDK 5.1.0, etc.) || Yes
|-
| nol_sdkdebug || Enables Debug Mode which allows output to be viewed in console. || <code>"console"</code> || No
|}
 
<syntaxhighlight lang="javascript">   var gg = window.NOLCMB.getInstance(instanceName /*optional*/);
    gg.ggInitialize(window._nolggGlobalParams);</syntaxhighlight>
'''For Flash integration'''
Instantiate Nielsen Browser SDK in the Flash player’s controller. Below is an example code for player setup & instantiation of the SDK.
<syntaxhighlight lang="javascript">    public function setupPlayer():void
     {
     {
      ggCom.getInstance(RootReference.stage.loaderInfo);
    return s=t.document,
      var setup:PlayerSetup = new PlayerSetup(_player, _model, _view);
    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,
    }</syntaxhighlight>
    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]
    }
  }
}


== Step 4: Configure and fire API calls ==
(window,"NOLBUNDLE");
The syntax for firing events is
var nSdkInstance = NOLBUNDLE.nlsQ("PXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "nlsnInstance");
<syntaxhighlight lang="javascript">    nSdkInstance.ggPM("event", metadataObject);</syntaxhighlight>
</script>
CMS data to be sent as an object in the format mentioned above.
</syntaxhighlight>
Event is passed in parameter 1 and the metadataObject is passed in parameter 2.
<br />
'''For Flash integration'''
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.
<syntaxhighlight lang="javascript">    ggCom.getInstance().PM('loadMetadata',_metadata);</syntaxhighlight>


=== loadMetadata ===
===Create SDK Instance===
Use [[loadMetadata (Browser)]] to pass ‘content’ and ‘ad’ [[metadata]]. The CMS data must be passed as a JSON object.
<br/>
<syntaxhighlight lang="javascript">    nSdkInstance.ggPM("loadMetadata", metadataObject);</syntaxhighlight>
To initialize the SDK, create an SDK instance by making the initialization call:
Refer to [[loadMetadata (Browser)]] for the list of parameters to be passed in the JSON object.
<blockquote>Note: Trigger the [[loadMetadata (Browser)]] call with content metadata ("type": "content") before sending any "preroll" ad metadata.</blockquote>


=== setPlayheadPosition (Content) ===
'''Initialization API Call'''
Use [[setPlayheadPosition (Browser)]] to pass the position of the playhead while the content is being played.
<syntaxhighlight lang="javascript"> 
NOLBUNDLE.nlsQ("<apid>", "<instanceName>",{nol_sdkDebug: "debug"})
</syntaxhighlight>
<br />
When creating an instance, pass the following three values:
{| class="wikitable"
{| class="wikitable"
|-
|-
! # !! Key !! Description !! Values !! Required? (Y/N) !! Example
! Parameter !! Description !! Values
|-
|-
| 1 || Live** || UTC of the live content || Client-defined || Yes || Seconds since 1970
| apid || Unique ID assigned to player/site || 'PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
|-
|-
| 2 || Video On Demand (VOD)** || Position taken from beginning of the content in seconds. || Client-defined || Yes || Current player position from beginning of the content.
|instanceName || Name of SDK instance || "any string value"
|}
<nowiki>**</nowiki>Only one of these parameters is mandatory
===== For Flash integration =====
'''Video On Demand (VOD) Content'''
<syntaxhighlight lang="javascript">    ggCom.getInstance().PM('setPlayheadPosition', position);</syntaxhighlight>
'''Live Content'''
<syntaxhighlight lang="javascript">    ggCom.getInstance().PM('setPlayheadPosition', (Date.now()/1000));</syntaxhighlight>
 
=== setPlayheadPosition (Ad) ===
Use [[setPlayheadPosition (Browser)]] to pass the position of the playhead for every one second while the advertisement is being played.
{| class="wikitable"
|-
|-
! Key !! Description !! Values !! Required? (Y/N) !! Example
| nol_sdkDebug || Enables Nielsen console logging. Only required for testing || "{nol_sdkDebug: "debug"})"
|-
| Ad || Position taken from beginning of the ad in seconds || Client-defined || Yes || Seconds since start of the ad
|}
|}
<br/>
'''Example SDK Initialization'''


=== stop ===
<syntaxhighlight lang="javascript">
Call [[stop (Browser)]] when switching between content and ads, and also on pause.
'''For Flash integration'''
var nSdkInstance = NOLBUNDLE.nlsQ("PXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX", "nlsnInstance", {nol_sdkDebug: "debug"});
<syntaxhighlight lang="javascript">   ggCom.getInstance().PM('stop', position);</syntaxhighlight>


=== end ===
</syntaxhighlight>
Call [[end (Browser)]] only at the end of playback (but before a postroll occurs, if postrolls are inserted). Call [[play (Browser)]] when resuming the stream / starting a new stream.
<br/>
'''For Flash integration'''
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.
<syntaxhighlight lang="javascript">    ggCom.getInstance().PM('end', position);</syntaxhighlight>
<br/>
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”.
<br/>
'''Example SDK Configuration'''
<br/>
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">  


=== API Call sequence ===
<script type="text/javascript">
==== Use Case 1: Content has no Advertisements ====
  // Add Static Queue Snippet
Call [[loadMetadata (Browser)]] with JSON metadata for content as below.
!function(t,n)
<syntaxhighlight lang="json">{
{
  "type": "content",
  t[n]=t[n]||{nlsQ:function(e,o,c,r,s,i)
  "assetid": "vid345-67483",
  {
  "program": "ProgramName",
    return s=t.document,
  "title": "Program S3, EP1",
    r=s.createElement("script"),
  "length": "3600",
    r.async=1,
  "segB": "CustomSegmentValueB",
    r.src=("http:"===t.location.protocol?"http:":"https:")+"//cdn-gl.imrworldwide.com/conf/"+e+".js#name="+o+"&ns="+n,
  "segC": "CustomSegmentValueC",
    i=s.getElementsByTagName("script")[0],
  "crossId1": "Reference11",
    i.parentNode.insertBefore(r,i),
  "crossId2": "Reference22",
    t[o]=t[o]||{g:c,ggPM:function(n,e,c,r,s){(t[o].q=t[o].q||[]).push([n,e,c,r,s])}},
  "isfullepisode": "y",
    t[o]
  "airdate": "20161013 20:00:00",
  }
  "adloadtype": "2",
}
  "hasAds": "0"
}
}</syntaxhighlight>
(window,"NOLBUNDLE");
Call [[setPlayheadPosition (Browser)]] every one second until a pause / stop.
Use the sample API sequence below as a reference to identify the specific events that need to be called during content playback without ads.
{| class="wikitable"
|-
! Type !! Sample code !! Description
|-
| Start of stream || <code>nSdkInstance.ggPM(loadMetadata, contentMetadataObject);</code> || // contentMetadataObject contains the JSON metadata for the content
|-
| Content || <code> nSdkInstance.ggPM(setPlayheadPosition, playheadPosition);</code> || // playheadPosition is position of the playhead while the content is being played
|-
| End of Stream || <code>nSdkInstance.ggPM(end, playheadPosition);</code> || // playheadPosition is position of the playhead while the content is being played
|}


==== Use Case 2: Content has Advertisements ====
  // Created SDK Instance
Call [[loadMetadata (Browser)]] with JSON metadata for ad as below.
  var nSdkInstance = NOLBUNDLE.nlsQ("XXXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX","nlsnInstance", {nol_sdkDebug: "debug"});
<syntaxhighlight lang="json">{
</script>
  "type": "preroll",
</syntaxhighlight>
  "assetId_ad": "ad=123"
}</syntaxhighlight>
<blockquote>Note: In case the individual ad details are not available, send ad pod (presence) details through the [[loadMetadata (Browser)]] and playhead position through [[setPlayheadPosition (Browser)]].</blockquote>
 
Call [[setPlayheadPosition (Browser)]] every one second until a pause / stop / another ''loadMetadata'' is called. Playhead should be passed for the entire duration of ad pod, if the ad pod details are passed as part of [[loadMetadata (Browser)]].


The sample API sequence can be used as a reference to identify the specific events that need to be called during content and ad playback.
=== Create Metadata Objects ===
<br/>
There are two types of asset metadata:
<br/>
*content: identify video
*ad: identify each ad
<br/>
The metadata received for each asset is used for classification and reporting.
<br/>
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.
<br/>
''Content Metadata''
<br/>
Content metadata should remain constant throughout the completion of an episode / clip including the ads play.
<br/>
{| class="wikitable"
{| class="wikitable"
|-
|-
! Type !! Sample code !! Description
! Key !! Description !! Values !! Required
|-
|-
| Start of stream || <code>nSdkInstance.ggPM(loadMetadata, contentMetadataObject);</code> || // contentMetadataObject contains the JSON metadata for the content
| clientid ||  
parent ID – value is automatically populated through provided App ID.<br/>
In order to override the brand configured to the App ID, pass parent <br/>
value here and the sub-brand ID associated to that brand in the subbrand <br/>
key (e.g. multiple brands in App)
||
Nielsen provided
||
|-
|-
| rowspan="3" | Preroll || <code>nSdkInstance.ggPM(loadMetadata, prerollMetadataObject);</code> || // prerollMetadataObject contains the JSON metadata for preroll ad
| vcid || sub-brand ID – value is automatically populated through provided<br/>
App ID. In order to override the sub-brand configured to the App ID, value can <br/>
be passed here (e.g. multiple sub-brands in App)
||
Nielsen provided
||
|-
|-
| <code>nSdkInstance.ggPM(setPlayheadPosition, playheadPosition);</code> || // playheadPosition is position of the playhead while the preroll ad is being played
| type || type of asset || "content" || ✓
|-
|-
| <code>nSdkInstance.ggPM(stop, playheadPosition);</code> || // Call stop after preroll occurs
| assetid || unique ID assigned to asset || custom || ✓
|-
|-
| rowspan="3" | Content || <code>nSdkInstance.ggPM(loadMetadata, contentMetadataObject);</code> || // contentMetadataObject contains the JSON metadata for the content being played
| program || name of program (25 character limit) || custom || ✓
|-
|-
| <code>nSdkInstance.ggPM(setPlayheadPosition, playheadPosition);</code> || // playheadPosition is position of the playhead while the content is being played
| title || episode title (40 character limit) || custom || ✓
|-
|-
| <code>nSdkInstance.ggPM(stop, playheadPosition);</code> || // Call stop after the content is paused (ad starts)
| length || length of content in seconds || seconds 86400 for live stream)|| ✓
|-
|-
| rowspan="3" | Midroll || <code>nSdkInstance.ggPM(loadMetadata, midrollMetadataObject);</code> || // midrollMetadataObject contains the JSON metadata for the midroll ad
| mediaURL || URL location of the content being streamed || custom ||
|-
|-
| <code>nSdkInstance.ggPM(setPlayheadPosition, playheadPosition);</code> || // playheadPosition is position of the playhead while the midroll ad is being played
| segB || custom segment B || custom ||
|-
|-
| <code>nSdkInstance.ggPM(stop, playheadPosition);</code> || // Call stop after midroll occurs
| segC || custom segment C || custom ||
|-
|-
| rowspan="3" | Content (End of stream) || <code>nSdkInstance.ggPM(loadMetadata, contentMetadataObject);</code> || // contentMetadataObject contains the JSON metadata for the content being played
| airdate || the airdate in the linear TV || YYYYMMDD HH:MI:SS || ✓
|-
|-
| <code>nSdkInstance.ggPM(setPlayheadPosition, playheadPosition);</code> || // playheadPosition is position of the playhead while the content is being played
| isfullepisode || full episode flag ||
*"y"– full episode
*"n"– non full episode
||
|-
|-
| <code>nSdkInstance.ggPM(end, playheadPosition);</code> || // Called at the end of content
| crossId1 || standard episode ID || custom || ✓
|-
|-
| rowspan="3" | Postroll || <code>nSdkInstance.ggPM(loadMetadata, postrollMetadataObject);</code> || // postrollMetadataObject contains the JSON metadata for the postroll ad
| crossId2 || content originator (only required for distributors) || Nielsen provided ||
|-
|-
| <code>nSdkInstance.ggPM(setPlayheadPosition, playheadPosition);</code> || // playheadPosition is position of the playhead while the postroll ad is being played
|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
||
|-
|-
| <code>nSdkInstance.ggPM(stop, playheadPosition);</code> || // Call stop after postroll occurs
| hasAds || identify if content includes Ads ||
*“0” – no ads
“1” – includes Ads
“2” – unknown (default)
||
|}
|}
<br/>
'''Example Content Object'''
<syntaxhighlight lang="javascript">
var contentMetadataObject =
  type:          'content',
  assetid:        'VID123-123456',
  program:        'program name',
  title:          'episode title',
  length:        'length in seconds',
  mediaURL:      'http://www.site.com/videoAsset',
  segB:          'custom segment B',
  segC:          'custom segment C',
  airdate:        'YYYYMMDD HH:MI:SS',
  isfullepisode:  'y',
  crossId1:      'Standard Episode ID',
  crossId2:      'Content Originator',
  adloadtype:    '2',
  hasAds:        '1'
};
</syntaxhighlight>


<blockquote>Note: Each Ad playhead should reset or begin from 0 at ad start. When content has resumed following an ad break, playhead position must continue from where previous content segment was left off.</blockquote>
=== Ad Metadata Object ===
 
<br/>
'''For Flash integration'''
The ad metadata should be passed for each individual ad.
<br/>
{| class="wikitable"
{| class="wikitable"
|-
|-
! Type !! Sample code !! Description
! Keys !! Description !! Values !! Required
|-
|-
| Start of stream || <code>ggCom.getInstance().PM(‘loadMetadata’,contentMetadataObject);</code> || // contentMetadataObject contains the JSON metadata for the content
| type || type of ad || 'preroll', 'midroll', or 'postroll' ||
|-
|-
| rowspan="3" | Preroll || <code>ggCom.getInstance().PM(loadMetadata, prerollMetadataObject);</code> || // prerollMetadataObject contains the JSON metadata for preroll ad  
| assetid || unique ID assigned to ad || custom || ✓
|}
<br/>
'''Example Ad Object'''
<br/>
<syntaxhighlight lang="javascript"
var adMetadataObject =
  assetid: 'AD-1',
  type:    'preroll'
};
</syntaxhighlight>
<br/>
<blockquote> 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. </blockquote>
<br/>
'''Call Nielsen APIs'''
<br/>
The method for calling events is ggPM().
<br/>
<syntaxhighlight lang="javascript"> 
nSdkInstance.ggPM('event', parameter, ...);
 
</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
<br/>
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>
<br/>
<blockquote>User may need to add code to support specific browser versions (e.g. older versions of Internet Explorer).</blockquote>
<br/>
 
<br/>
'''SDK Events'''
<br/>
{| class="wikitable"
|-
|-
| <code>ggCom.getInstance().PM(setPlayheadPosition, playheadPosition);</code> || // playheadPosition is position of the playhead while the preroll ad is being played
! Event !! Parameter !! Description
|-
|-
| <code>ggCom.getInstance().PM(stop, playheadPosition);</code> || // Call stop after preroll occurs
| 'loadMetadata' || content/ad metadata object || Needs to be called at the beginning of each asset
|-
|-
| rowspan="3" | Content || <code>ggCom.getInstance().PM(loadMetadata, contentMetadataObject);</code> || // contentMetadataObject contains the JSON metadata for the content being played
| 'setPlayheadPosition' || playhead position as integer<br/>
VOD: || current position in seconds <br/>
Live: current UTC timestamp <br/>
Note: 'setPlayheadPosition' has to be called every second
||
Pass playhead position every second during playback
|-
|-
| <code>ggCom.getInstance().PM(setPlayheadPosition, playheadPosition);</code> || // playheadPosition is position of the playhead while the content is being played
| 'stop' || playhead position || Call when content or ads complete playing and pass playhead position
|-
|-
| <code>ggCom.getInstance().PM(stop, playheadPosition);</code> || // Call stop after the content is paused (ad starts)
| 'end' || playhead position in seconds || Call when the current video asset completes playback and pass the playhead position. <br/>
|-
Example: At the end of the content stream, if the user switches to another piece of content, when the browser is refreshed or closed.
| rowspan="3" | Midroll || <code>ggCom.getInstance().PM(loadMetadata, midrollMetadataObject);</code> || // midrollMetadataObject contains the JSON metadata for the midroll ad
|-
| <code>ggCom.getInstance().PM(setPlayheadPosition, playheadPosition);</code> || // playheadPosition is position of the playhead while the midroll ad is being played
|-
| <code>ggCom.getInstance().PM(stop, playheadPosition);</code> || // Call stop after midroll occurs
|-
| rowspan="3" | Content (End of stream) || <code>ggCom.getInstance().PM(loadMetadata, contentMetadataObject);</code> || // contentMetadataObject contains the JSON metadata for the content being played
|-
| <code>ggCom.getInstance().PM(setPlayheadPosition, playheadPosition);</code> || // playheadPosition is position of the playhead while the content is being played
|-
| <code>ggCom.getInstance().PM(end, playheadPosition);</code> || // Called at the end of content
|-
| rowspan="3" | Postroll || <code>ggCom.getInstance().PM(loadMetadata, postrollMetadataObject);</code> || // postrollMetadataObject contains the JSON metadata for the postroll ad
|-
| <code>ggCom.getInstance().PM(setPlayheadPosition, playheadPosition);</code> || // playheadPosition is position of the playhead while the postroll ad is being played
|-
| <code>ggCom.getInstance().PM(stop, playheadPosition);</code> || // Call stop after postroll occurs
|}
|}
<br/>
== SDK Playhead Event Sequence ==
<br/>
The sample event lifecycle can be used as a reference for identifying the order for calling events.
<br/>
<syntaxhighlight lang="javascript"> 
// 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);
// MIDROLL
nSdkInstance.ggPM('loadMetadata', midrollMetadataObject);
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('end', playheadPosition);
// POSTROLL
nSdkInstance.ggPM('loadmetadata', postrollMetadataObject);
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
// 
//  pass playhead every second
// 
nSdkInstance.ggPM('setPlayheadPosition', playheadPosition);
nSdkInstance.ggPM('stop', playheadPosition);
</syntaxhighlight>
<blockquote>
* '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'.


== Nielsen Measurement Opt-Out Implementation ==
* For Ad Pods, events must be called for each individual Ad. Each Ad playhead position should begin at ‘0’ when ad starts.
As a global information and measurement leader, we are committed to protecting the privacy and security of the data we collect, process and use. Our digital measurement products are not used to identify the consumer in any way, but they help us and our clients measure and analyze how consumers engage with media across online, mobile and emerging technologies, and offer insights into consumer behavior.


When the user wants to opt in or opt out of Nielsen measurement, a new dynamic page (with content similar to http://secure-us.imrworldwide.com/nielsen_app_optout.html) should be displayed.
* 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.
</blockquote>


For more details, refer to [[Browser SDK API Reference#Browser Opt-Out Implementation|Browser SDK API Reference - Browser Opt-Out Implementation]] and Nielsen Digital Privacy.
* Use [[getOptOutStatus (Browser)]] to retrieve the user’s current Opt-Out status.


== Pre-Certification Checklists ==
== Nielsen Opt-Out ==
After the application is ready to be sent for Nielsen Certification, please go through the Pre-Certification Checklist and ensure the app behaves as expected, before submitting to Nielsen.
<br/>
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.
<br/>
*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://www.nielsen.com/digitalprivacy.
<br/>
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.
<br/>
The following paragraph is a template for an opt-out statement.
<Br/>
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://www.nielsen.com/digitalprivacy.
<br/>
'''Opt Back In'''
<br/>
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.
<br/>
'''Going Live'''
<br/>
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.
<br/>
Disable debug logging by deleting {nol_sdkDebug: 'DEBUG'} from initialization call.
Example Production Initialization Call


== Testing an Implementation - App ==
<syntaxhighlight lang="javascript">
See [[Digital Measurement Testing]].
 
var nSdkInstance = NOLBUNDLE.nlsQ("PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "nlsnInstance");
 
</syntaxhighlight>

Revision as of 21:00, 10 August 2017

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

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.

   
       apid: "PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"

Configure SDK


There are two steps required for configuring the SDK:

  • Add Static Queue Snippet
  • Create SDK Instance


Static Queue Snippet
Add the following script tag to the website:

 
<script>
!function(t,n)
{
  t[n]=t[n]||
  {
    nlsQ:function(e,o,c,r,s,i)
    {
     return s=t.document,
     r=s.createElement("script"),
     r.async=1,
     r.src=("http:"===t.location.protocol?"http:":"https:")+"//cdn-gl.imrworldwide.com/conf/"+e+".js#name="+o+"&ns="+n,
     i=s.getElementsByTagName("script")[0],
     i.parentNode.insertBefore(r,i),
     t[n][o]=t[n][o]||{g:c||{},
     ggPM:function(e,c,r,s,i){(t[n][o].q=t[n][o].q||[]).push([e,c,r,s,i])}},t[n][o]
    }
  }
}

(window,"NOLBUNDLE");
var nSdkInstance = NOLBUNDLE.nlsQ("PXXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "nlsnInstance");
</script>


The static queue snippet allows the SDK APIs to be called while the actual SDK and configuration file are still being downloaded. As the queue can capture all API calls before the download completes, there is no wait time. Once the SDK is available, the API calls will transition from directing to the queue to the SDK seamlessly.

Create SDK Instance


To initialize the SDK, create an SDK instance by making the initialization call:

Initialization API Call

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


When creating an instance, pass the following three values:

Parameter Description Values
apid Unique ID assigned to player/site 'PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'
instanceName Name of SDK instance "any string value"
nol_sdkDebug Enables Nielsen console logging. Only required for testing "{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.bundle.min.js”.
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[o]=t[o]||{g:c,ggPM:function(n,e,c,r,s){(t[o].q=t[o].q||[]).push([n,e,c,r,s])}},
    t[o]
   }
 }
} 
(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 completion of an episode / clip including the ads play.

Key Description Values Required
clientid

parent ID – value is automatically populated through provided App ID.
In order to override the brand configured to the App ID, pass parent
value here and the sub-brand ID associated to that brand in the subbrand
key (e.g. multiple brands in App)

Nielsen provided

vcid 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
be passed here (e.g. multiple sub-brands in App)

Nielsen provided

type type of asset "content"
assetid unique ID assigned to asset custom
program name of program (25 character limit) custom
title episode title (40 character limit) custom
length length of content in seconds seconds 86400 for live stream)
mediaURL URL location of the content being streamed custom
segB custom segment B custom
segC custom segment C custom
airdate the airdate in the linear TV YYYYMMDD HH:MI:SS
isfullepisode full episode flag
  • "y"– full episode
  • "n"– non full episode

crossId1 standard episode ID custom
crossId2 content originator (only required for distributors) Nielsen provided
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

hasAds identify if content includes Ads
  • “0” – no ads

“1” – includes Ads “2” – unknown (default)


Example Content Object

 
var contentMetadataObject =
{  
  type:           'content',
  assetid:        'VID123-123456',
  program:        'program name',
  title:          'episode title',
  length:         'length in seconds',
  mediaURL:       'http://www.site.com/videoAsset',
  segB:           'custom segment B',
  segC:           'custom segment C',
  airdate:        'YYYYMMDD HH:MI:SS',
  isfullepisode:  'y',
  crossId1:       'Standard Episode ID',
  crossId2:       'Content Originator',
  adloadtype:     '2',
  hasAds:         '1'
};

Ad Metadata Object


The ad metadata should be passed for each individual ad.

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


Example Ad Object

  
var adMetadataObject = 
{  
  assetid: 'AD-1',
  type:    'preroll'
};


URL Character Limit: There is a URL character limit of 2K characters due to browser limitations. Exceeding this value could impair data delivery on particular browsers.


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


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


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
Live: current UTC timestamp
Note: 'setPlayheadPosition' has to be called every second

Pass playhead position every second during playback

'stop' playhead position 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 lifecycle can be used as a reference for identifying the order for calling events.

  
// 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);
 
// MIDROLL
nSdkInstance.ggPM('loadMetadata', midrollMetadataObject);
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('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.


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 http://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.
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://www.nielsen.com/digitalprivacy.
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
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("PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "nlsnInstance");