DCR Denmark Video Browser SDK

From Engineering Client Portal

Revision as of 15:07, 1 March 2021 by MichelFodjo (talk | contribs) (Example of GN ping)

Engineering Portal breadcrumbArrow.png Digital breadcrumbArrow.png International DCR breadcrumbArrow.png DCR Denmark Video Browser SDK


The Nielsen SDK is one of multiple framework SDKs that Nielsen provides to enable measuring linear (live) and on-demand TV viewing using TVs, mobile devices, etc. The Browser SDK (BSDK) is the framework for browser application developers to integrate Nielsen Measurement into their media players. It supports a variety of Nielsen Measurement Products like Digital in TV Ratings (DTVR) and Digital Content Ratings (DCR). Nielsen SDKs are also equipped to measure static content and can track key life cycle events.


Before you start the integration, you will need:

Item Description Source
App ID (appid) Unique ID assigned to the player/site and configured by product. Contact Nielsen

Configure SDK

There are two steps required for configuring the SDK:

  • Add Static Queue Snippet
  • Create SDK Instance

Add Static Queue Snippet

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

Add the following script tag to the website i.e. within the <head></head> tag :

  function t(e){
    return"object"==typeof e?JSON.parse(JSON.stringify(e)):e
      var s=e.document,
      var i=s.getElementsByTagName("script")[0];
      return i.parentNode.insertBefore(a,i),
      ggPM:function(o,c,s,a,i){e[n][r].q=e[n][r].q||[];try{var l=t([o,c,s,a,i]);e[n][r].q.push(l)}
catch(e){console&&console.log&&console.log("Error: Cannot register event in Nielsen SDK queue.")}},
      trackEvent:function(o){e[n][r].te=e[n][r].te||[];try{var c=t(o);e[n][r].te.push(c)}
catch(e){console&&console.log&&console.log("Error: Cannot register event in Nielsen SDK queue.")}}},

Create SDK Instance

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

Initialization API Call

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

For creating an instance, pass the following values: (nol_sdkDebug is optional)

Parameter Description Values
appid Unique ID assigned to player/website "PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
instanceName Name of SDK instance "any string value"
nol_sdkDebug Enables Nielsen console logging if desired.
{nol_sdkDebug: "debug"}

When the initialization call is made, a unique static configuration file, <appid>.js, will be downloaded based on the appid and will be cached on the user’s browser.

Sample SDK Initialization Call

var nSdkInstance = NOLBUNDLE.nlsQ("PXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX", "nlsnInstance", {
    nol_sdkDebug: "debug"

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

Create Metadata Objects

Before starting any measurement of an asset(Content or Ad) with the created SDK Instance, you need to create an asset metadata object in order to identify the asset. There are two types of asset metadata:

  • content: identify a video
  • ad: identify each ad

The metadata received for each asset is used for classification and reporting.

Metadata are passed through key-values using the Nielsen reserved keys. You will need to set up content and ad objects with the required Nielsen keys as shown in the sample code below.

Create Content Metadata

Content metadata should remain constant throughout the entirety of an episode/clip including when ads play.

program and title metadata values should be passed to SDK as UTF-8 strings.

Keys Description Values Required
type type of asset "content" for main content
assetid unique ID assigned to asset custom
(no Special Characters)
program name of program custom
title episode name custom
length length of content in seconds Length of content in seconds (86400 seconds for live stream (24/7). For Event-Live streams planned length. For VoD video length)
airdate the original date (local time with hh:mm:ss as 24h time stamp) content became available. This date does not change if the content is rebroadcasted on linear TV. YYYYMMDD HH:MI:SS (if not known set it to eg. "19700101 00:00:00")
isfullepisode full episode flag
  • "y" full episode (full content for a program)
  • "n" non full episode (only one part of the entire content for a program , i.e. preview, sub-episodes)

adloadtype type of Ad load
  • "1" Linear - matches TV ad load
  • "2" Dynamic - Dynamic Ad Insertion (DAI)

subbrand vcid/sub-brand/Channel ID – value is automatically populated through provided AppID. In order to override the sub-brand configured to the App ID, value can be passed here (e.g. multiple sub-brands/Channels in the App) provided by Nielsen
Example Content Object
var contentMetadataObject =
  type:           "content",
  assetid:        "unique_content_id",
  program:        "program name",
  title:          "episode title",
  length:         "length in seconds",
  airdate:        "20200713 10:22:00",
  isfullepisode:  "y",
  adloadtype:     "2",

Create Ad Metadata (optional for DR)

The Ad Metadata (if applicable) should be passed for each individual ad.

Note: All metadata values should be passed as UTF-8 strings.

Keys Description Values Required
type type of Ad "preroll", "midroll", "postroll"
"ad" - If specific type can not be identified.
assetid unique ID assigned to Ad custom
(no Special Characters)
subbrand vcid/sub-brand/Channel ID – value is automatically populated through provided AppID. In order to override the sub-brand configured to the App ID, value can be passed here (e.g. multiple sub-brands/Channels in the App) provided by Nielsen
Example Ad Object
var adMetadataObject = 
  type:    "preroll",
  assetid: "unique_preroll_ad_id"

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.

Start the Measurement

Nielsen APIs calls are made by calling the function ggPM("event", parameter, ...) with "event" Parameter indicating the SDK API.

nSdkInstance.ggPM("event", parameter, ...);

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 Unix timestamp (seconds since Jan-1-1970 UTC)
Note: "setPlayheadPosition" has to be called every second

Pass playhead position every second during playback

"sendID3" ID3 tag payload retrieved from the stream Call when the video player has read ID3 tag in the stream
"stop" playhead position in seconds Call when content or ads complete playing and pass playhead position
"end" playhead position in seconds Call when the current video asset completes playback and pass the playhead position.

Example: At the end of the content stream, if the user switches to another piece of content, when the browser is refreshed or closed.

Start the measurement by calling the "event" names "loadMetadata" followed by "setPlayheadPosition".

// START OF STREAM  (main content)
nSdkInstance.ggPM("loadMetadata", contentMetadataObject); 
// CONTENT plays
// pass playhead every second
nSdkInstance.ggPM("setPlayheadPosition", playheadPosition);

Stop/Resume the Measurement for video Playback Interruptions

Handle Video Playback Interruption

The setPlayheadPostion event is used for handling playback interruption. To indicate that the video player is not playing (i.e. paused, buffering), stop passing the playhead position to the SDK. Once the Playback resumes , begin sending the playhead position again with the correct playhead value.

List of video Playback Interruptions

The following possible video Playback Interruptions must be handled:

  • Player PAUSED
  • Player BUFFERING
  • Browser/Tab close
  • Leaving the page to another destination
  • Pressing the stop button
  • Network Loss

Example for handling Playback Interruption: Browser/Tab close/Page Reload

window.addEventListener("beforeunload", function(event) 
  // Only inside an Ad indicate <stop> for the ad
  nSdkInstance.ggPM("stop", playheadPosition);
  // Indicate <end> for the content
  nSdkInstance.ggPM("end", playheadPosition);

Note: additional code may be needed in order to support specific browser versions (e.g. older versions of Internet Explorer).

Send ID3 Tags when available in the stream

// ID3 Tag read from the stream (HLS or MPEG-DASH)
// pass ID3 Tag to SDK
nSdkInstance.ggPM("sendID3", id3);

More details will be added soon. The ID3 Tag integration will happen after CMS-Tag Integration.

SDK Call Sequence

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

Content Playback Call Sequence

nSdkInstance.ggPM("loadMetadata", contentMetadataObject); 
// CONTENT plays
// pass playhead every second
nSdkInstance.ggPM("setPlayheadPosition", playheadPosition);
nSdkInstance.ggPM("end", playheadPosition);

Ad Playback Call Sequence (Optional for DR)

nSdkInstance.ggPM("loadMetadata", adMetadataObject); 
// Ad plays
// pass playhead every second
nSdkInstance.ggPM("setPlayheadPosition", playheadPosition);
// END OF Ad
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" or "end".
  • For Ad Pods, events must be called for each individual Ad. Each Ad playhead position should begin at "0" when an 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.

Review SDK Integration Architecture Diagram

For Content Playback

SDK Integration Architecture Diagram - Content

For Ad Playback

SDK Integration Architecture Diagram - Ad

Reference Implementation for VoD and Live Streams

The Reference Implementation covers vod and Live use cases. It also covers DAI (Dynamic Ad Insertion) with preroll and postroll Ads.

In order to start live stream select the checkbox "isLive" below the video player.

Start the Reference Implementation for DK sdkRefImplDK.


The privacy section will be added soon.

Test your player by yourself


1. Run your player in the Browser, start a video
2. Open the Developer Network View in order to monitor network traffic
3. Filter the network traffic by "nmr" and confirm presence of GN pings

Example of GN ping


Provide your app for certification

Once ready please send your application to Nielsen local staff for certification.

Going Live

After the integration has been certified (but not prior that), disable debug logging by deleting {nol_sdkDebug: "DEBUG"} from Initialization API Call.