DCR Czech Video App SDK

From Engineering Client Portal

Engineering Portal / Digital / International DCR / DCR Czech Video App 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 for Android and iOS operating systems.
It supports a variety of Nielsen Measurement Products like Digital in TV Ratings, Digital Content Ratings (DCR & DTVR), Digital Ad Ratings (DAR), Digital Audio.
This guide covers implementation steps for iOS using Xcode and Android using Android Studio.

Prerequisites

To start using the App SDK, the following details are required:

  • App ID (appid): Unique ID assigned to the player/site and configured by product.
  • Nielsen SDK: The Nielsen SDK package contains AppSDK itself and sample player for your reference - download package at Digital Downloads

If you do not have any of these prerequisites or if you have any questions, please contact our SDK sales support team - see Czech Contacts.

Step 1: Setting up your Development Environment

iOS

Configuring Xcode Development Environment

Starting with SDK version 6.0.0.0, the Nielsen App SDK is compatible with Apple iOS versions 8.0 and above. In addition, the SDK uses the WKWebView class instead of the deprecated UIWebView as per Apple guidelines.

Note: All communications between the SDK and the Census (Collection Facility) use HTTPS.

Importing Frameworks

1) Extract “NielsenAppApi.Framework” from the Nielsen App SDK sample app and copy it to Frameworks folder of the Xcode project.

2) Import following frameworks and libraries into the Frameworks of the Xcode project before creating an instance of the Nielsen App SDK object.

  • UIKit.framework
  • Foundation.framework
  • AdSupport.framework
  • SystemConfiguration.framework
  • Security.framework
    • Nielsen Analytics framework makes use of a number of functions in this library.
  • AVFoundation.framework
    • This framework is mandatory for the iOS SDK version 5.1.1 to work.
  • CoreLocation.framework
  • CoreMedia.framework
  • NielsenAppApi.framework
  • libc++.tbd (as SDK contains Objective C++ source file)
    • Alternatively, include -lstdc++ in Build Settings → Other Linker Flag of the Xcode project

3) Add the code -#import NielsenAppApi/NielsenAppApi.h to the View Controller’s header file.

Note:

  • Nielsen App SDK is compatible with Apple iOS versions 9.0 and above.
  • The SDK uses the NSURLSession instead of the deprecated NSURLConnection.
  • All communications between the SDK and the Census (Collection Facility) use HTTPS


Using Swift

To import a set of Objective-C files in the same app target as your Swift code, you rely on an Objective-C bridging header to expose those files to Swift. Xcode offers to create this header file when you add a Swift file to an existing Objective-C app, or an Objective-C file to an existing Swift app.

Select File/New File/Objective-C File
Xcode will prompt you to create a bridging header.

bridgingheader 2x.png

Once this file has been created, you need to add the following:

#import <NielsenAppApi/NielsenAppApi.h>

Using Objective-C

Add the code

#import <NielsenAppApi/NielsenAppApi.h>
to the View Controller’s header file.



Java

Configuring Android Development Environment


1) Ensure to unzip the Nielsen App SDK sample app and copy the AppSdk.jar into the app/libs folder on the App’s project. Add it as dependency.
2) Add the following permissions on the project’s AndroidManifest.xml file.

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:required="false" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>

3) Add Google Play Services lib into dependencies as Nielsen AppSDK uses the following packages/classes from the Google Play service. Libraries:

  • com.google.android.gms:play-services

Requiered Google Play Service CLasses and Packages :

  • com.google.android.gms.ads.identifier.AdvertisingIdClient;
  • com.google.android.gms.ads.identifier.AdvertisingIdClient.Info;
  • com.google.android.gms.common.ConnectionResult;
  • com.google.android.gms.common.GooglePlayServicesUtil;
  • com.google.android.gms.common.GooglePlayServicesRepairableException;
  • com.google.android.gms.common.GooglePlayServicesNotAvailableException;

4) Once the files are in place, import com.nielsen.app.sdk to the java source code and start accessing the public interface.

import com.nielsen.app.sdk.*;


Notes:

  • The Nielsen App SDK (located in the com.nielsen.app.sdk package) class is the primary application interface to the Nielsen App SDK on Android.
  • The Nielsen App SDK class is defined as the only public class belonging to the com.nielsen.app.sdk package.
  • Nielsen App SDK is compatible with Android OS versions 2.3+.
  • Clients can control / configure the protocol to be used – HTTPS or HTTP to suit their needs.
  • The Android OS hosting the App SDK should use a media player supporting HLS streaming (Android 3.0 and later will support it natively).
  • If the player application uses a 3rd party media player implementing its own HLS, then the minimum Android version will be limited to version 2.3, since the SDK depends on Google Play support to work properly.

Step 2: SDK Initialization

The latest version of the Nielsen App SDK allows instantiating multiple instances of the SDK object, which can be used simultaneously without any issue. The sharedInstance API that creates a singleton object was deprecated prior to version 5.1.1. (Version 4.0 for Android)

  • A maximum of four SDK instances per appid are supported. When a fifth SDK instance is launched, the SDK will return “nil” from initWithAppInfo:delegate:
  • When four SDK instances exist, you must destroy an old instance before creating a new one.

The following table contains the list of arguments that can be passed via the AppInfo JSON schema.

Parameter / Argument Description Source Required/Obligatory? Example
appid Unique id for the application assigned by Nielsen. It is GUID data type. Nielsen-specified PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
appname Name of the application Client-defined No Nielsen Sample App
appversion Current version of the app used Client-defined No "1.0.2"
sfcode Nielsen collection facility to which the SDK should connect. Put "cz" (for both dev phase + testing and production) Nielsen-specified "cz"
nol_devDebug Enables Nielsen console logging. Only required for testing Nielsen-specified Optional "DEBUG"


Sample SDK Initialization Code

Swift

Swift 4.0 Example: NielsenInit.swift

class NielsenInit: NSObject {
    class func createNielsenAppApi(delegate: NielsenAppApiDelegate) -> NielsenAppApi?{
    let appInformation:[String: String] = [
           "appid": "PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
            "appversion": "1.0",
            "appname": "app name here",
            "sfcode": "cz",
            "nol_devDebug": "DEBUG"
        ]
        return NielsenAppApi(appInfo:appInformation, delegate:delegate)
    }
}


Sample code using AVPlayer.
ViewController.swift

class ViewController: UIViewController, NielsenAppApiDelegate, AVPictureInPictureControllerDelegate, CLLocationManagerDelegate  {

    let avPlayerViewController = AVPlayerViewController()
    var avPlayer:AVPlayer?
    var nielsenAppApi: NielsenAppApi!

  override func viewDidLoad() {
        super.viewDidLoad()

        self.nielsenAppApi = NielsenInit.createNielsenAppApi(delegate: self)
        NSLog("Nielsen SDK initialized")

            }
  }

Objective C

Initialize the Nielsen App object within the viewDidLoad view controller delegate method using initWithAppInfo:delegate:

If App SDK is initialized using init or new methods, it will ignore the API calls resulting in no measurement. The SDK will not return any errors.

#import "NlsAppApiFactory.h"
#import <NielsenAppApi/NielsenAppApi.h>

@implementation NlsAppApiFactory

+ (NielsenAppApi *)createNielsenAppApiWithDelegate:(id<NielsenAppApiDelegate>)delegate;
{
    NSDictionary *appInformation = @{
                                     @"appid": "PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
                                     @"appversion": "1.0",
                                     @"appname": "app name here",
                                     @"sfcode": "cz",
                                     @"nol_devDebug": @"DEBUG"
                                     };
    return [[NielsenAppApi alloc] initWithAppInfo:appInformation delegate:delegate];
}
@end


The following would be the NlsAppApiFactory.h file:

#import <Foundation/Foundation.h>

@class NielsenAppApi;
@protocol NielsenAppApiDeligate;

@interface NlsAppApiFactory : NSObject

+ (NielsenAppAPI *) createNielsenAppApiWithDelegate:(id<NielsenAppApiDelegate>)delegate;

@end

Java

1) AppSDK() is no longer a singleton object and should be initialized as below.

try{
  // Prepare AppSdk configuration object (JSONObject)
  JSONObject appSdkConfig = new JSONObject()
          .put("appid", "PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")
          .put("appversion", "1.0")
          .put("appname", "Sample App Name")
          .put("sfcode", "cz")
          .put("nol_devDebug", "DEBUG"); // only for debug builds

         // Pass appSdkConfig to the AppSdk constructor
         mAppSdk = new AppSdk(appContext, appSdkConfig, this);
}
catch (JSONException e){
         Log.e(TAG, "Couldn’t prepare JSONObject for appSdkConfig", e);
}

2) implement IAppNotifier into your activity like

public class MainActivity extends AppCompatActivity implements IAppNotifier

3) implement callback

@Override
public void onAppSdkEvent(long timestamp, int code, String description){
  Log.d(TAG, "SDK callback onAppSdkEvent " + description);
}

So whole Activity will look like

package com.example.josefvancura.nlsdemotmp;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;

import com.nielsen.app.sdk.*;

import org.json.JSONException;
import org.json.JSONObject;

public class MainActivity extends AppCompatActivity implements IAppNotifier {

    private AppSdk mAppSdk = null;
    private String TAG = "MainActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Context context = getApplicationContext();

        try{
            // Prepare AppSdk configuration object (JSONObject)
            JSONObject appSdkConfig = new JSONObject()
                    .put("appid", "TF2D48D99-9B58-B05C-E040-070AAB3176DB")
                    .put("appversion", "1.0")
                    .put("appname", "Sample App Name")
                    .put("sfcode", "cz")
                    .put("nol_devDebug", "DEBUG"); // only for debug builds

            // Pass appSdkConfig to the AppSdk constructor
            mAppSdk = new AppSdk(context, appSdkConfig, this ); // Notifier - activity implements IAppNotifier, callback in onAppSdkEvent()

        }
        catch (JSONException e){
            Log.e(TAG, "Couldn’t prepare JSONObject for appSdkConfig", e);
        }

    }

    @Override
    public void onAppSdkEvent(long timestamp, int code, String description) {
        Log.d(TAG, "SDK callback onAppSdkEvent " + description);
    }

}

APP SDK Error & Event Codes

To view the Error and Event codes for iOS and Android, please review the App SDK Event Code Reference page.

Life cycle of SDK instance

Life cycle of SDK instance includes four general states:

  1. Initial state – The SDK is not initialized and hence, not ready to process playing information. Once the SDK is moved out of this state, it needs instantiation of the new SDK instance in order to get the instance in the Initial state.
  2. Idle state – The SDK is initialized and is ready to process playing information. Once Initialized, the SDK instance is not processing any data, but is listening for the play event to occur.
  3. Processing state – The SDK instance is processing playing information. API calls "play" and "loadMetadata" move the SDK instance into this state. In this state, the SDK instance will be able to process the API calls (see below)
  4. Disabled state – The SDK instance is disabled and is not processing playing information. SDK instance moves into this state in one of the following scenarios.
    1. Initialization fails
    2. appDisableApi is called
@property (assign) BOOL appDisableApi;

Step 3: Create Metadata Objects

The parameters passed must be either a JSON formatted string or a NSDictionary object. The JSON passed in the SDK must be well-formed.

  • NSDictionary object
    • If an object of unexpected type is passed to the method, the error message will be logged.
    • If string has invalid JSON format, the error message will be logged.
  • JSON value must be string value.
    • This includes boolean and numeric values. For example, a value of true should be represented with "true", number value 123 should be "123".
    • All the Variable Names like appid, appname, sfcode, dataSrc, title, type etc. are case-sensitive. Use the correct variable name as specified in the documentation.
  • JSON string can be prepared using either raw NSString or serialized NSDictionary.


ChannelName metadata

channelName should remain constant throughout the completion of an episode or live stream.

Key Description Values Required
channelName Any string representing the channel/stream custom

Content metadata

Content metadata should remain constant throughout the entirety of an episode/clip including when ads play. For detailed information of metadata and custom variables see Czech SDK Metadata.

Ad Metadata

The ad metadata (if applicable) should be passed for each individual ad, if ads are available during or before the stream begins. For detailed information of metadata and custom variables see Czech SDK Metadata.


MetaData Example

Swift

     let channelInfo = [
        "channelName": "My Channel Name 1",
     ]

     let contentMetadata = [
       "assetid" : "c1",
        "type" : "content",
        "program" : "myProgram",
        "title" : "Anime Movie",
        "length" : "52",
        "mediaUrl" : "",
        "airdate" : "20161013 20:00:00",
        "isfullepisode" : "y",
        "crossId1" : "9827411",
        "nol_c1" : "p1,",
        "nol_c2" : "p2,TVident",
        "segB" : "Programový typ",
        "segC" : "",
        "adloadtype" : "1",
        "hasAds" : "1"
     ]

    let adMetadata = [
        "assetid" : "ad1",
        "type" : "midroll",
        "length" : "34",
        "title" : "Ad Renault",
        "nol_c4" : "p4,ASMEA code for ad",
        "nol_c5" : "p5,Atribut for ad",
        "nol_c6" : "p6,midroll",
        "nol_ac" : "ad"
    ]

Objective C

NSDictionary  *channelInfo = @
{
  @"channelName":@"My Channel Name 1",
}

NSDictionary *contentMetadata = @
  {
  @"assetid" : "c1",
  @"type" : "content",
  @"program" : "myProgram",
  @"title" : "Anime Movie",
  @"length" : "52",
  @"mediaUrl" : "",
  @"airdate" : "20161013 20:00:00",
  @"isfullepisode" : "y",
  @"crossId1" : "9827411",
  @"nol_c1" : "p1,",
  @"nol_c2" : "p2,TVident",
  @"segB" : "Programový typ",
  @"segC" : "",
  @"adloadtype" : "1",
  @"hasAds" : "1"
}

NSDictionary *adMetadata = @
  {
  @"assetid" : "ad1",
  @"type" : "midroll",
  @"length" : "34",
  @"title" : "Ad Renault",
  @"nol_c4" : "p4,ASMEA code for ad",
  @"nol_c5" : "p5,Atribut for ad",
  @"nol_c6" : "p6,midroll",
  @"nol_ac" : "ad"
}

Java

JSONObject channelInfo = new JSONObject()
    .put("channelname","My Channel Name 1")

JSONObject contentMetadata = new JSONObject()
   .put("assetid", "assetid_example")
   .put("type", "content")
   .put("program", "ProgramName")
   .put("title", "Bunny in Woods")
   .put("length", "579") // 9min 39sec
   .put("mediaUrl", "") // empty
   .put("airdate", "20171013 20:00:00")
   .put("isfullepisode", "y")
   .put("crossId1", "IDEC")
   .put("nol_c1", "p1,") // empty for VOD
   .put("nol_c2", "p2,TV ident")
   .put("segB", "Program type")
   .put("segC", "") // empty
   .put("adloadtype", "1")
   .put("hasAds",  "1");

JSONObject adMetadata = new JSONObject()
   .put("assetid", "assetid_example_postroll")
   .put("type", "postroll")
   .put("length", "30")
   .put("title", "Nielsen postroll")
   .put("nol_c4", "p4,ASMEAcode")
   .put("nol_c5", "p5,AtributForAd")
   .put("nol_c6", "p6,postroll");

Step 4: Configure API Calls

API Calls Types

play

The play method prepares the SDK for reporting once an asset has loaded and playback has begun. Use play to pass the channel descriptor information through channelName parameter when the user taps the Play button on the player. Call play only when initially starting the video.

Swift

self.nielsenAppApi?.play(channelInfo);

Objective C

nielsenAppApi play:(JSONObject channelInfo);

Java

mAppSdk.play(JSONObject channelInfo);

loadMetadata

Needs to be called at the beginning of each asset, pass JSON object for relevant content or ad. Make sure to pass as 1st loadMetadata for content at the begining of playlist - see below API call sequence examples.

Swift

self.nielsenAppApi?.loadMetadata(contentMetadata)

Objective C

nielsenAppApi loadMetadata:(id)contentMetadata;

Java

mAppSdk.loadMetadata(JSONObject contentMetadata);

playheadPosition

Pass playhead position every second during playback. for VOD: pass current position in seconds. for Live: current Unix timestamp (seconds since Jan-1-1970 UTC) - if it is possible to seek back in Live content, then pass related Unix time (not current). Pass whole number that increments only by 1 like 1,2,3..

Swift

self.nielsenAppApi?.playheadPosition(pos);

Objective C

nielsenAppApi playheadPosition: (long long) playheadPos

Java

mAppSdk.setPlayheadPosition(long videoPositon);

stop

Call when

  • content or ads complete playing
  • when a user pauses playback
  • upon any user interruption scenario - see bellow chapter Interruption scenario

Swift

self.nielsenAppApi?.stop

Objective C

nielsenAppApi stop

Java

mAppSdk.stop();

end

Call when the content asset completes playback. Stops measurement progress.

Swift

self.nielsenAppApi?.end

Objective C

nielsenAppApi end;

Java

mAppSdk.end();


API Call sequence

Use Case 1: Content has no Advertisements

Only content in playlist, A Sample API sequence follow this flow:

Playlist Sample code Description
1. Start of stream play(channelName) channelName contains JSON metadata of channel/video name being played
loadMetadata(contentMetadataObject) contentMetadataObject contains the JSON metadata for the content being played
2. Content playheadPosition(position) playheadPosition is position of the playhead while the content is being played
3. End of Stream end Content playback is completed.

Use Case 2: Content has Advertisements

Playlist : ad preroll - content - ad midroll - content continues - ad postroll.
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.

Playlist Sample code Description
1. Start of stream play(channelName); channelName contains JSON metadata of channel/video name being played
loadMetadata(contentMetaDataObject); contentMetadataObject contains the JSON metadata for the content being played
2. Preroll loadMetadata(prerollMetadataObject); prerollMetadataObject contains the JSON metadata for the preroll ad
setPlayheadPosition(playheadPosition); position is position of the playhead while the preroll ad is being played
stop(); Call stop after preroll occurs
3. Content loadMetadata(contentMetaDataObject); contentMetadataObject contains the JSON metadata for the content being played
setPlayheadPosition(playheadPosition); position is position of the playhead while the content is being played
stop(); Call stop after the content is paused (ad starts)
4. Midroll loadMetadata(midrollMetaDataObject); midrollMetadataObject contains the JSON metadata for the midroll ad
setPlayheadPosition(playheadPosition); position is position of the playhead while the midroll ad is being played
stop(); Call stop after midroll occurs
5. Content (End) loadMetadata(contentMetaDataObject); contentMetadataObject contains the JSON metadata for the content being played
setPlayheadPosition(playheadPosition); position is position of the playhead while the content is being played
stop(); Always call stop irrespective of postroll is followed or not
6. End of Stream end(); Call end() at the end of content
7. Postroll loadMetadata(postrollMetaDataObject); postrollMetadataObject contains the JSON metadata for the postroll ad
setPlayheadPosition(playheadPosition); position is position of the playhead while the postroll ad is being played
stop(); Call stop after postroll occurs

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.

Step 5: Interruptions during playback

As part of integrating Nielsen App SDK with the player application, the Audio / Video app developer needs to handle the following possible interruption scenarios:

  • Pause / Play
  • Network Loss (Wi-Fi / Airplane / Cellular)
  • Call Interrupt (SIM or Third party Skype / Hangout call)
  • Alarm Interrupt
  • Content Buffering continues for 30 seconds
  • Device Lock / Unlock (Video players only, not for Audio players)
  • App going in the Background/Foreground (Video players only, not for Audio players)
  • Channel / Station Change Scenario
  • Unplugging of headphone

In case of encountering one of the above interruptions, the player application needs to

  • Call stop immediately (except when content is buffering) and withhold sending playhead position.
  • Start sending pings – loadMetadata and playheadPosition for the new viewing session, once the playback resumes.

Please see the Digital Measurement FAQ for more details

Privacy and Opt-Out

iOS

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

  1. OS-level Opt-out - managed by Limit Ad Tracking setting on device (preferred approach).
  2. Legacy Opt-out - Direct call to SDK; used only for older versions of Nielsen iOS SDK (< 5.1.1.18)

OS-level Opt-out

OS-level Opt-out method available on Nielsen iOS SDK Versions 5.1.1.18 and above.

The Nielsen SDK automatically leverages the iOS's Limit Ad Tracking setting. The user is opted out of demographic measurement if the OS-level "Limit Ad Tracking" ("Limit Ad Tracking" for Android) setting is enabled. As a publisher, you cannot override this setting.

Legacy Opt-out

The Legacy opt-out method is only necessary for Nielsen iOS SDK versions less than 5.1.1.18.

Nielsen iOS SDK 5.1.1.17 and above will check for OS-level opt-out first, if available. The user will be opted out if indicated at the OS-level OR the App-level.

The legacy opt-out method works as follows:

  • Get the legacy Nielsen opt-out URL via optOutURL
  • Display a WebView element whose loadUrl is set to the value obtained from optOutURL
  • Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView
    • Opt-out if the WebView URL : nielsenappsdk://1
    • Opt-in if the WebView URL : nielsenappsdk://0
  • Pass the detected URL to the userOptOut function
    • Example:
      NielsenAppApi?.userOptOut("nielsenappsdk://1"); // User opt-out
      

Legacy Opt-out example code

var webView: WKWebView!
var NIELSEN_URL_OPT_OUT : String = "nielsenappsdk://1"
var NIELSEN_URL_OPT_IN : String = "nielsenappsdk://0"

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {

       let urlStr = navigationAction.request.url?.absoluteString

        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){
            let appApi = self.nielsenApi
            appApi?.userOptOut(urlStr)
            decisionHandler(.allow)

        }else{
           decisionHandler(.cancel)
        }
    }

Retrieve current Opt-Out preference

Whether the user is opted out viaOS-level Opt-out or via App-level Opt-out, the current Opt-Out status as detected by the SDK is available via the optOutStatus property in the Nielsen SDK API

Required Privacy Links

Users must either have access to the "About Nielsen Measurement" page, or have similar text available within the native app. Include "About Nielsen Measurement" and "Your Choices" link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.

In addition, the following text must be included in your app store description.

"Please note: This app features Nielsen’s proprietary measurement software which contributes to market research, like Nielsen’s TV Ratings. Please see https://priv-policy.imrworldwide.com/priv/mobile/cz/cs/optout.html for more information"

Webview Example

The below code is an example of displaying the Nielsen Privacy page to the user.

import UIKit
import WebKit
import NielsenAppApi

class OptOutVC: UIViewController, NielsenAppApiDelegate, WKNavigationDelegate {
    
    var webView: WKWebView!
    var nielsenApi: NielsenAppApi!
    
    override func loadView() {
        webView = WKWebView()
        webView.navigationDelegate = self
        view = webView
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: "new_ios_bg.png")!) 
        self.nielsenApi = NielsenInit.createNielsenApi(delegate: self)
        
        if let appApi = self.nielsenApi {
            //Getting the optPut URL from SDK
            if let url = URL(string: appApi.optOutURL) {
                webView.load(URLRequest(url: url))
                webView.allowsBackForwardNavigationGestures = true
            }
        }
    }
    
}




Java

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

  1. OS-level Opt-out - managed by Opt out of Ads Personalization setting on device (preferred approach).
  2. Legacy Opt-out - Direct call to SDK; used only for older versions of Nielsen Android SDK versions (< 5.1.1.18)

OS-level Opt-out

OS-level Opt-out method available on Nielsen Android SDK Versions 5.1.1.18 and above.

The Nielsen SDK automatically leverages the Android's Opt out of Ads Personalization setting. The user is opted out of demographic measurement if the OS-level "Opt out of Ads Personalization" ("Limit Ad Tracking" for iOS) setting is enabled. As a publisher, you cannot override this setting.

Legacy Opt-out

The Legacy opt-out method is only necessary for Nielsen Android SDK versions less than 5.1.1.18, or where Google Play Services are not available.

Nielsen Android SDK 5.1.1.18 and above will check for OS-level opt-out first, if available. The user will be opted out if indicated at the OS-level OR the App-level.

The legacy opt-out method works as follows:

  • Get the current Nielsen opt-out URL via userOptOutURLString()
  • Display a WebView element whose loadUrl is set to the value obtained from userOptOutURLString()
  • Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView
    • Opt-out if the WebView URL : nielsenappsdk://1
    • Opt-in if the WebView URL : nielsenappsdk://0
  • Pass the detected URL to the userOptOut() function
    • Example:
      appSdk.userOptOut("nielsenappsdk://1");  // User opt-out
      

Legacy Opt-out example code

public class OptOutActivity extends AppCompatActivity implements IAppNotifier {

WebView webView;
AppSdk appSdk;

  private static final String NIELSEN_URL_OPT_OUT = "nielsenappsdk://1";
  private static final String NIELSEN_URL_OPT_IN = "nielsenappsdk://0";
 
//  Within your app you would provide your User the option to Opt Out.
//  Perhaps via a toggle or button
//  This is separate from Limit Ad Tracking 

      let urlStr = navigationAction.request.url?.absoluteString

        if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){
            let appApi = self.nielsenApi
            appApi?.userOptOut(urlStr)
}

Retrieve current Opt-Out preference

Whether the user is opted out viaOS-level Opt-out or via App-level Opt-out, the current Opt-Out status as detected by the SDK is available via the getOptOutStatus() property in the Nielsen Android SDK API,

Required Privacy Links

Users must either have access to the "About Nielsen Measurement" page, or have similar text available within the native app. Include "About Nielsen Measurement" and "Your Choices" link in the Privacy Policy / EULA or as a button near the link to the app's Privacy Policy.

In addition, the following text must be included in your app store description.

"Please note: This app features Nielsen’s proprietary measurement software which contributes to market research, like Nielsen’s TV Ratings. Please see http://priv-policy.imrworldwide.com/priv/mobile/cz/cs/optout.html for more information"

Webview Example

The below code is an example of displaying the Nielsen Privacy page to the user.

public class OptOutActivity extends AppCompatActivity implements IAppNotifier {

    WebView webView;
    AppSdk appSdk;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_optout);
        webView = (WebView) findViewById(R.id.webView);

        webView.getSettings().setJavaScriptEnabled(true);

        webView.setWebViewClient(new WebViewClient() {
            @SuppressWarnings("deprecation")
            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                Toast.makeText(OptOutActivity.this, description, Toast.LENGTH_SHORT).show();
            }
            @TargetApi(android.os.Build.VERSION_CODES.M)
            @Override
            public void onReceivedError(WebView view, WebResourceRequest req, WebResourceError rerr) {
                // Redirect to deprecated method, so you can use it in all SDK versions
                onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());
            }
        });

        NielsenInit nielsenInit = new NielsenInit();
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);
        //Getting the optPut URL from eventTracker
        String url = appSdk.userOptOutURLString();
        webView.loadUrl(url);
    }


Step 7 : Test your player by yourself

Guide

1. Connect your PC and test device (tablet or phone) via same router.
2. PC side: run Proxy sw (like Charles) and get local IP
3. Test device: modify Wifi setting to pass throug Proxy IP from add 2
4. Test device: run your player, launch video
5. PC side: filter trafic by "imr" and confirm presence of GN pings

for Android see https://youtu.be/zOKOinb-zdc, for iOS see https://youtu.be/Gk0YQttiXRI

Example of GN ping

http://secure-eu-cert.imrworldwide.com/cgi-bin/gn?prd=dcr&ci=de-205177&ch=de-205177_c01_P&asn=defChnAsset&tl=Bunny%2520in%2520Woods&prv=1&c6=vc,c01&ca=de-205177_c01_assetid&cg=ProgramName&c13=asid,T885AAE54-AFE4-431D-B60B-FF4C75FCA357&c32=segA,NA&c33=segB,CustomSegmentValueB&c34=segC,CustomSegmentValueC&c15=apn,CZ%20demo%20player&sup=1&segment2=-1&segment1=cze&forward=0&ad=1&cr=4_00_99_V1_00000&c9=devid,d6df553edcc70bf62812069af7252d5e905399c711378b6ee0a1f0a9381fdec6&enc=true&c1=nuid,62ef4e4aeb2c3d390c224e3aaf686ec063895e9dd9a64f4d2b84059e1148e29c&at=view&rt=video&c16=sdkv,aa.5.1.1&c27=cln,0&crs=0&lat=&lon=&c29=plid,T885AAE54-AFE4-431D-B60B-FF4C75FCA357&c30=bldv,aa.5.1.1.18&st=dcr&c7=osgrp,DROID&c8=devgrp,TAB&c10=plt,MBL&c40=adbid,&c14=osver,Android6.0.1&c26=dmap,1&dd=&hrd=&wkd=&c35=adrsid,&c36=cref1,IDEC&c37=cref2,&c11=agg,1&c12=apv,1.0.1&c51=adl,0&c52=noad,0&sd=596&devtypid=asus-Nexus-7&pc=NA&c53=fef,y&c54=oad,20171013%2020%3A00%3A00&c55=cref3,&c57=adldf,1&ai=assetid&c3=st%252Cc&c64=starttm,1500474035&adid=assetid&c58=isLive,false&c59=sesid,1500474032&c61=createtm,1500474037&c63=pipMode,&c60=agfall,p0%252C~~p1%252Ccontent%2520-%2520ID%2520for%2520content%2520matching%2520TVIDENT~~p2%252Ccontent%2520-%2520Reserved%2520for%2520future%2520use~~st%252Cc21:31, 13 September 2018 (UTC)~&c62=sendTime,1500474123&c68=bndlid,com.example.kunalbhatia.hlsexomy&nodeTM=&logTM=&c73=phtype,Tablet&c74=dvcnm,Google+Nexus+7&c76=adbsnid,&df=-1&c77=adsuprt,1&evdata=&c71=ottflg,0&c72=otttyp,&sessionId=&c44=progen,&davty=0&si=&c66=mediaurl,&uoo=&vtoff=86&rnd=1500474122131

Step 8 : Provide your app for certification

Once ready please send your application to Nielsen local staff for verification - see Czech Contacts.

Step 9 : Going Live

After the integration has been certified (but not prior that), disable debug logging by deleting {nol_sdkDebug: 'DEBUG'} from initialization call - see Step 2.

Demos

see live demos with sample implementation available at at http://sdkdemo.admosphere.cz/

FAQs

  • Question: When to instantiate Nielsen SDK?
  • Answer: At application start and only once during runtime.


  • Question: Which API calls shall be executed and when?
  • Answer:
    • For standard runtime - please see Chapter 4 - API Call sequence
    • For interruption scenario - see Chapter 5 Interruptions during playback