Simplified SDK API
From Engineering Client Portal
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 App SDK, the following details are required:
- App ID (appid): Unique ID assigned to the player/site and configured by product.
- sfcode: Unique identifier for the environment that the SDK should point to.
- Nielsen SDK: The Nielsen SDK package contains a variety of sample players for your reference.
If you do not have any of these prerequisites or if you have any questions, 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.
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.
For iOS SDK framework package will contain 2 public header files. One header file will contain old SDK interface and will be used by existing clients (NielsenAppApi.h). New API will be defined in a new public header file (NielsenEventTracker.h).
For Android, a new wrapper class for AppSdk will be introduced (AppSdkTrackEvent). This class will be responsible for handling and translating new API calls into calls of the existing Nielsen App SDK API methods. A new public API will be introduced in this class, that accepts a JSONObject parameter.
Implementation
This guide covers implementation steps for iOS using Xcode and Android using Android Studio.
Setting up your Development Environment
xCode
Configuring Xcode Development Environment
Nielsen App SDK is compatible with Apple iOS versions 8.0 and above.
The SDK uses the NSURLSession instead of the deprecated NSURLConnection.
Note: All communications between the SDK and the Census (Collection Facility) use HTTPS.
Importing Frameworks The first step is to ensure that the following frameworks and libraries are imported into the Frameworks folder of the Xcode project before creating an instance of the Nielsen App SDK object.
- UIKit.framework
- Foundation.framework
- AdSupport.framework
- JavascriptCore.framework
- WebKit.framework
- SystemConfiguration.framework
- Security.framework
- Nielsen Analytics framework makes use of a number of functions in this library.
- AVFoundation.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
Example
- Extract “NielsenAppApi.Framework” from the Nielsen App SDK sample app and copy it to Frameworks folder of the Xcode project.
- Add the code
-#import NielsenAppApi/NielsenAppApi.h
to the View Controller’s header file.
Ensure that the following are included in the Linked Frameworks and Libraries list (located in the project’s Summary settings).
- Nielsen App SDK
- iOS security framework
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.
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'
- The Nielsen App SDK (located in the Downloads section of the website) 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 requirement for the Java AppSdk.jar library and the libAppSdk.so native library will depend on the type of host application that will make use of them.
- For Video player applications
- 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.
- For Audio player applications
- The Android OS hosting the App SDK should be at version 2.3 and later since the SDK depends on the Google Play support to work properly.
Once SDK is downloaded ensure to unzip the Nielsen SDK and copy the AppSdk.jar in your app (Android Studio) libs folder, then right click the AppSdk.jar and select Add As Library. Ensure the AppSdk.jar file is added in 'build.grade (App Level) file.
- App SDK 1.2 provides support for x86, mips, and armeabi-7a architecture.
Google Play Services
Add the Google Play Services in the project,
Steps: Android Studio -> File -> Project Structure ->(In module selection) select App -> Dependencies (tab) -> Click “+” button and select “com.google.android.gms:play-services”
.
Ensure it is added in build.gradle (App level) file
Manifest File
- 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"/>
For more details to handle runtime permissions in Android versions, please visit [1].
- In
AndroidManifest.xml
under <application> node add the following metadata
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
- App SDK checks to see if there is a Google service available and updated.
- If not available or updated, App SDK will not use this service when executing its functions and will make reference to missing imports and the app will not be compiled.
Library
Nielsen App SDK uses the following packages/classes from the Google Play service.
- google-play-services_lib
Classes/package
- 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;
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:
The following table contains the list of arguments that should be passed during initialization.
- The appid is provided by the Nielsen Technical Account Manager (TAM).
Parameter / Argument | Description | Source | Required? | Example |
---|---|---|---|---|
appid | Unique id for the application assigned by Nielsen.
It is GUID data type, provided by the Nielsen Technical Account Manager (TAM). |
Nielsen-specified | Yes | 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.
DTVR
Digital Audio
DCR
|
Nielsen-specified | Yes | "dcr" |
containerID | View ID of the UI element used as player view in application for Viewability | Client-defined | No | "1234567" |
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
import Foundation
import NielsenAppApi
class NielsenInit : NSObject {
class func createEventTracker(delegate: NielsenEventTrackerDelegate) -> NielsenEventTracker?{
//Initialising the NielsenEventTracker class by passing app information which returns the instance of NielsenEventTracker.
var nielsenEventTracker: NielsenEventTracker?
let appInformation = [
"appid": "PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX",
"appversion": "1.0",
"appname": "Amazing app",
"sfcode": "dcr",
"nol_devDebug": "DEBUG",
"containerId": String(containerId) //Keep container id unique constant, you can use tag property of player.
]
nielsenEventTracker = NielsenEventTracker(appInfo:appInformation1, delegate:delegate)
return nielsenEventTracker
}
}
Sample code: ViewController
ViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
//Getting the instance of NielsenEventTracker
self.nielsenEventTracker = NielsenInit.createEventTracker(delegate: self)
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.
Objective-C Example:
NielsenInit.m
#import "NielsenInit.h"
#import <NielsenAppApi/NielsenEventTracker.h>
@implementation NielsenInit
+ (NielsenEventTracker *)createNielsenEventTrackerWithDelegate:(id<NielsenEventTrackerDelegate>)delegate
{
//Initialising the NielsenEventTracker class by passing app information which returns the instance of NielsenEventTracker.
NSDictionary *appInformation = @{ @"appid": @"PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX",
@"appversion": @"1.0",
@"appname": @"Objc Test app",
@"sfcode": @"dcr",
@"nol_devDebug": @"INFO",
@"containerId": @"1" }; //Keep container id unique constant, you can use tag property of player.
return [[NielsenEventTracker alloc] initWithAppInfo:appInformation delegate:delegate];
}
The following would be the NielsenInit.h
file:
#import <Foundation/Foundation.h>
@class NielsenEventTracker;
@protocol NielsenEventTrackerDelegate;
@interface NielsenInit : NSObject
+ (NielsenEventTracker *)createNielsenEventTrackerWithDelegate:(id<NielsenEventTrackerDelegate>)delegate;
@end
The ViewController.m file could then contain the following line(s):
//Getting the instance of NielsenEventTracker
nielsenEventTracker = [NielsenInit createNielsenEventTrackerWithDelegate:nil];
/////
-(void) setPlayHeadPosition {
//Setting play head position
CMTime timeInterval = CMTimeMakeWithSeconds(1, 1);
[player addPeriodicTimeObserverForInterval:(timeInterval) queue:dispatch_get_main_queue() usingBlock:^(CMTime time){
NSTimeInterval seconds = CMTimeGetSeconds(time);
NSInteger intSec = seconds;
NSString* strSec = [NSString stringWithFormat:@"%li", intSec];
//updating playHead position in dictionary.
[mutableData setValue:strSec forKey:@"playheadPosition"];
//Sending data dictionary to SDK with updated playHead position.
[nielsenEventTracker trackEvent:mutableData];
}];
}
Java
Initialization of App SDK object through a JSON object
import android.content.Context;
import com.nielsen.app.sdk.IAppNotifier;
import com.nielsen.app.sdk.NielsenEventTracker;
import org.json.JSONException;
import org.json.JSONObject;
public class NielsenInit {
private NielsenEventTracker mEventTracker = null;
public NielsenEventTracker initEventTracker(Context mContext, IAppNotifier appNotifier){
try {
//Initialising the NielsenEventTracker class by passing app information which returns the instance of NielsenEventTracker.
JSONObject appInformation = new JSONObject()
.put("appid", "PDA7D5EE6-B1B8-4123-9277-2A788XXXXXXX")
.put("appversion", "1.0")
.put("appname", "Android Test app")
.put("sfcode", "dcr")
.put("nol_devDebug", "INFO")
.put("containerId", "55"); //Keep container id unique constant, you can use tag property of player.
mEventTracker = new NielsenEventTracker(mContext, appInformation, appNotifier);
} catch (JSONException e) {
e.printStackTrace();
}
return mEventTracker;
}
}
Initializing the Nielsen AppSDK to measure the Viewability
The integrator to support the viewability metrics in the application has to provide a tag value of the player view to let Nielsen AppSDK know that there is a player that needs to be tracked. It’s called the ‘containerId’ and it should be passed in application info dictionary as string while initializing the Nielsen AppSDK.
Android
# | Parameter Name | Description | Supported Values | Example |
---|---|---|---|---|
1 | containerId | View ID of the UI element used as player view in application. getId() method of View class can be used to get this value. | A positive integer used to identify the view. | 2131558561 |
iOS
# | Parameter Name | Description | Supported Values | Example |
---|---|---|---|---|
1 | containerId | The tag of the UIView that represents the Player View | The string value representing the NSInteger value with maximum value of NSIntegerMax that is related on 32- or 64-bit applications. | "100" "2131558561" |
For iOS it is required to link additional frameworks that are needed for viewability engine:
JavaScriptCore.framework
WebKit.framework
The Nielsen AppSDK uses a tracking WebView (TWV) approach. For more information on Viewability, please refer to Implementing Viewability with AppSDK.
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.
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:
xCode
- (void)trackEvent:(NSDictionary *)data;
Java
void trackEvent(JSONObject data);
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 | 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, UTC timestamp or id3 payload, ott information to the SDK. |
pause |
This event should be used to in the following cases: application enters background, any application interruptions, content playback is paused. (Pause is detected by SDK automatically only if time gap between commands in 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 |
|
"event":"playhead"
|
type | Determines the metadata object
that should be used for crediting. |
|
"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 or UTC timestamp | String
|
Position value is UTC timestamp:
Position value is playhead:
|
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 (86400 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 | ✓ |
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 |
|
"event":"playhead"
|
type | Determines the metadata object that should be used for crediting. |
|
"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 or UTC timestamp | String
|
Position value is UTC timestamp:
Position value is playhead:
|
id3Data | Nielsen ID3 payload string | Object
|
|
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 |
|
"event":"playhead"
|
type | Determines the metadata object that should be used for crediting. |
|
"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 or UTC timestamp | String
|
Position value is UTC timestamp:
Position value is playhead:
|
id3Data | Nielsen ID3 payload string | Object
|
|
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 (86400 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":"86400",
"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)
Static Metadata
Keys | Description | Values | Required |
---|---|---|---|
type | type identifier | "static" |
✓ |
assetid | unique ID assigned for each article/section | custom | ✓ |
section | Unique Value assigned to page/site section | HomePage | Yes |
segA | name of program (25 character limit) | custom | Yes |
segB | custom segment B | custom | |
segC | custom segment C | custom |
{
"static":
{
"type": "static",
"section": "homeSection",
"assetid": "AID885-9984",
"segA": "CustomSegmentValueA",
"segB": "CustomSegmentValueB",
"segC": "CustomSegmentValueC",
}
},
Putting it all together
Swift
func loadPreRollAd() -> [String : Any] {
//Loading Ad data
url = NSURL(string: "http://www.nielseninternet.com/NWCC-3002/prog_index.m3u8")
let content = [
"assetName":"Big Buck Bunny",
"assetid":"B66473",
"length":"3600",
"program":"MyProgram",
"segB":"CustomSegmentValueB",
"segC":"segmentC",
"title":"S2,E3",
"type":"content",
"section":"app_Mainpage",
"airdate":"20180120 10:00:00",
"isfullepisode":"y",
"crossId1":"Standard Episode ID",
"crossId2" :"Content Originator",
"adloadtype":"2"
]
let staticObj = [
"type":"static",
"section":"homeSection",
"segA":"CustomSegmentValueA",
"segB":"CustomSegmentValueB",
"segC":"CustomSegmentValueC"
]
let ad = [
"assetid":"AD12345",
"title":"ADTestTitle",
"adldx":"1",
"type":"preroll",
"length":"20"
]
let metadata = [
"content" : content,
"ad" : ad,
"static" : staticObj
] as [String : Any]
let data = [
"metadata" : metadata,
"event": "playhead",
"playheadPosition": "0",
"type": "ad",
] as [String : Any]
return data
}
Objective C
#import <Foundation/Foundation.h>
#import "SDKMethods.h"
@implementation SDKMethods
//Loading content Data
- (NSDictionary *)loadContentData
{
- (NSDictionary *)loadPreRollAd
{
self.url = [NSURL URLWithString:@"http://www.nielseninternet.com/NWCC-3002/prog_index.m3u8"];
//We should pass content dictionary also in Ad video.
NSDictionary *content = @{ @"assetName":@"ChromeCast1",
@"assetid":@"C77664",
@"length":@"3600",
@"program":@"MyProgram",
@"segB":@"CustomSegmentValueB",
@"segC":@"segmentC",
@"title":@"S2,E3",
@"type":@"content",
@"section":@"app_Mainpage",
@"airdate":@"20180120 10:00:00",
@"isfullepisode":@"y",
@"adloadtype":@"2",
@"channelName":@"My Channel 1",
@"pipMode":@"false" };
NSDictionary *ad = @{ @"assetid":@"AD12345",
@"title":@"ADTestTitle",
@"type":@"preroll",
@"length":@"20" };
NSDictionary *staticObj = @{ @"type":@"static",
@"section":@"homeSection",
@"segA":@"CustomSegmentValueA",
@"segB":@"CustomSegmentValueB",
@"segC":@"CustomSegmentValueC" };
//static data should be empty in Ad video
NSDictionary *metadata = @{ @"content" : content,
@"ad" : ad,
@"static" : @staticObj };
NSDictionary *data = @{ @"metadata" : metadata,
@"event": @"playhead",
@"type": @"ad",
@"playheadPosition": @"0" };
return data;
}
Java
//Loading Ad data
public JSONObject loadPreRollAdData(){
JSONObject data = null;
url = "http://www.nielseninternet.com/NWCC-3002/prog_index.m3u8";
try {
//We should pass content dictionary also in Ad video.
JSONObject content = new JSONObject()
.put( "assetName","ChromeCast1")
.put( "assetid","C77664")
.put( "length","3600")
.put( "program","MyProgram")
.put( "segB","CustomSegmentValueB")
.put( "segC","segmentC")
.put( "title","S2,E3")
.put( "type","content")
.put( "section","app_Mainpage")
.put( "airdate","20180207 10:00:00")
.put( "isfullepisode","y")
.put( "adloadtype","2");
JSONObject ad = new JSONObject()
.put("type", "static")
.put("assetid", "AD12345")
.put("title", "ADTestTitle")
.put("type", "preroll")
.put("length", "20");
JSONObject staticObj = new JSONObject()
.put("type","static")
.put("section","homeSection")
.put("segA","CustomSegmentValueA")
.put("segB","CustomSegmentValueB")
.put("segC","CustomSegmentValueC");
JSONObject metaData = new JSONObject()
.put("content", content)
.put("ad", ad)
.put("static", staticObj);
data = new JSONObject()
.put("metadata", metaData)
.put("event", "playhead")
.put("type", "ad")
.put("playheadPosition", "0");
} catch (JSONException e) {
e.printStackTrace();
}
return data;
}
}
JSON examples
Additional JSON examples such as:
- Static Metadata Only
- Ad Metadata Example
- ID3 payload for DTVR
- Sample Pause Event
- Sample Complete Event
Handling Foreground and Background states
iOS
For iOS, background/foreground detection is handled by the app lifecylce APIs which are provided by Apple:
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement.
Java
Foreground/Background state measurement is a requirement of Nielsen AppSDK implementation which is especially crucial for static measurement. It may be implemented in multiple ways for Android. This includes
- Enable the Nielsen SDK to measure background/foreground state by makingthe relevant update to the AndroidManifest.
- Integrate Nielsen’s SdkBgFgDetectionUtility class within your Custom Application Class.
- Custom implementation of the required methods within your application.
ForeGround/Background Measurement via AndroidManifest
The simplest way to measure the app background/foreground state is to add the following application tag to the Manifest XML. Integrating this into the Manifest XML will enable the SDK to measure app state directly. This approach is supported for Android 4.0 and up only; it requires that the application class is not in use for some other purpose.
<application android:name="com.nielsen.app.sdk.AppSdkApplication">
Using the Android SdkBgFbDetectionUtility Class
For developers who are already using the application class, it is recommended that background/foreground state is implemented using the SdkBgFgDetectionUtility class. The SdkBgFgDetectionUtility class is compatible with Android 4+ and has been made available to Nielsen clients.
Manual Background/ForeGround State Management
In cases where the developer is not able to use the AndroidManifest.xml solution nor the Nielsen provided SdkBgFgDetectionUtility class the developer will need to manually identify the change of state through the application and call the respective API (appInForeground() or appInBackground()) to inform the SDK regarding the change of state from background to foreground or foreground to background.
The SDK is informed about app state using the below methods.
AppLaunchMeasurementManager.appInForeground(getApplicationContext());
AppLaunchMeasurementManager.appInBackground(getApplicationContext());
Within the lifecycle of individual activities, onResume() and onPause() are best suited to providing indication of the app state.
Correct measurement of the foreground/background state is crucial to Static App measurement within Nielsen Digital Content Ratings (DCR).
Privacy and Opt-Out
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.
- URL to this web page should be called from SDK by invoking userOptOutURLString() and opened in 'WebView' / External browser.
- If the App SDK returns NULL as Opt-Out URL, handle the exception gracefully and retry later.
- To retrieve the current Opt-Out status of a device, use the userOptOutURLString() method.
public String userOptOutURLString()
public boolean getOptOutStatus()
Users can opt out or opt back into Nielsen Measurement. Opt-Out feature relies on the system setting – "Limit Ad Tracking". The setting can be accessed in the Settings application on any device. User is opted out of Nielsen online measurement research when the "Limit Ad Tracking" setting is enabled.
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://www.nielsen.com/digitalprivacy for more information"
Sample Applications
The below sample applications have been designed to show the Simplified API's functionality and are broken into two distinct categories:
- Basic - To show the functionality of the Nielsen Simplified API using a standard no-frills player.
- Advanced - Nielsen Simplified API integrated into a custom video player.
- Swift 4.0 Sample
- Objective-C Sample
- Java/Android Studio Sample