Czech Digital Measurement iOS Simplified SDK
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.
If you do not have any of these prerequisites or if you have any questions, please see Contact list for Czech Republic.
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).
Implementation
This guide covers implementation steps for iOS using Xcode.
Step 1 : Get SDK
For AppSDK versions, release dates and release notes - refer to iOS AppSDK release notes.
Always keep latest and greatest AppSDK version inside your app.
The Nielsen AppSDK can either be
- integrated directly within an application through the use of a CocoaPod (iOS) or Gradle (Android) - select to read CocoaPod implementation guide - Recommended solution that will keep your SDK copy latest by each build. Once finished continue to Step 3.
- or downloaded as ZIP package at Nielsen Downloads. Package contains NielsenAppApi.framework (Static and Dynamic versions) as well as sample applications. You will have to update SDK manually always when new version of AppSDK is released. Once finished continue to Step 2.
Step 2 : Setting up your xCode Development Environment
Applicable only if using downloaded Framework package
From AppSDK version 6.2 (5.2.2018) - Dynamic Framework
Prior to SDK Version 6.2.0.0 the iOS framework has been distributed as a static library packaged into framework bundle format. Apple recommends to use dynamic framework, it has some benefits over static libraries like less executable file size of an app, faster startup time and native support in xCode IDE. Nielsen AppSDK has been transformed into dynamic framework in this release.
If migrating from the static library to this new dynamic framework, once implemented, unless your specific application requires, you can remove the following Frameworks that were once required: [AdSupport, JavascriptCore, SystemConfiguration, Security, AVFoundation, libc++].
Proceed :
1) From Nielsen SDK package - inside DynamicFramework dir - extract “NielsenAppApi.Framework” and copy it to Frameworks folder of the Xcode project.
2) Add Framework - In the General tab for app configuration add NielsenAppApi.framework in the list of Embedded Binaries.
3) Add Path - Add path to the NielsenAppApi.framework in the Framework Search Paths build setting.
Before AppSDK version 6.2 (5.2.2018) - Static Framework - Depreciated
From Nielsen SDK package - inside StaticFramework dir - extract “NielsenAppApi.Framework”. For futher steps refer to Step 1: Setting up your Development Environment inside DCR Czech Video App SDK (standard API).
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
Step 3: Import SDK
Add SDK import
a) Using Objective-C :
Add the code to the View Controller’s header file
#import <NielsenAppApi/NielsenAppApi.h>
b) Using Swift :
Add the code to the ViewController.swift
import NielsenAppApi
Alternatively using Objective-C bridging header : 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 bridging header file has been created, you need to add the following:
#import <NielsenAppApi/NielsenAppApi.h>
Step 4 : 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. 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.
Parameter / Argument | Description | Source | Required? | Example |
---|---|---|---|---|
appid | Unique id for the application assigned by Nielsen. It is GUID data type | 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. | Nielsen-specified | Yes | "cz" |
nol_devDebug | Enables Nielsen console logging. Only required for testing | Nielsen-specified | Optional | "DEBUG" |
Sample SDK Initialization Code - Swift
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": "cz",
"nol_devDebug": "DEBUG"
]
nielsenEventTracker = NielsenEventTracker(appInfo:appInformation1, delegate:delegate)
return nielsenEventTracker
}
}
ViewController.swift
override func viewDidLoad() {
super.viewDidLoad()
//Getting the instance of NielsenEventTracker
self.nielsenEventTracker = NielsenInit.createEventTracker(delegate: self)
}
Sample SDK Initialization Code - 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.
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": @"cz",
@"nol_devDebug": @"DEBUG"
};
return [[NielsenEventTracker alloc] initWithAppInfo:appInformation delegate:delegate];
}
NielsenInit.h
#import <Foundation/Foundation.h>
@class NielsenEventTracker;
@protocol NielsenEventTrackerDelegate;
@interface NielsenInit : NSObject
+ (NielsenEventTracker *)createNielsenEventTrackerWithDelegate:(id<NielsenEventTrackerDelegate>)delegate;
@end
Init SDK inside ViewController.m
#import "ViewController.h"
#import "NielsenInit.h"
@interface ViewController ()
@property (nonatomic, strong) NielsenAppApi *nielsenAppApi;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"viewDidLoad - app started");
//Getting the instance of NielsenEventTracker
nielsenEventTracker = [NielsenInit createNielsenEventTrackerWithDelegate:nil];
}
...
}
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.
Step 5 : 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:
self.nielsenEventTracker?.trackEvent(TrackEventData)
TrackEvent 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>
}
Passed parametres
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 |
Object
|
"metadata":{
"content": <content_metadataObject>,
"ad": <ad_metadataObject>,
"static": <static_metadataObject>
},
|
playheadPosition | Playhead value | String
|
For Live Stream : Position value is UTC timestamp:
For VOD : Position value is playhead:
|
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. |
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 specitication of Content Metadata for Czech Republic. Send content metadata for every playheadposition update.
When content is playing, pass only metadata for content - like
let metadata:[String: String] = [
"content": <content metadata object>,
"ad": "",
"static": ""
]
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 specitication of Content Metadata for Czech Republic.
When ad is playing, pass metadata for ad and its content as well - like
let metadata:[String: String] = [
"content": <content metadata object>,
"ad": <ad metadata object>,
"static": ""
]
Static Metadata
Note : static is currently used in Czech Republic only for Browser implementations, not apps. Please leave metadata empty - like
let metadata:[String: String] = [
...
"static": ""
]
Putting it all together (example for ad)
// content
let metaDataContent:[String: String] = [
"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" : "2",
"hasAds" : "1"
]
// ad
let metaDataAd:[String: String] = [
"assetid": "ad1",
"type": "postroll",
"length": "15",
"title": "Ad Tostoriros",
"nol_c4": "p4,ASMEA code for ad",
"nol_c5": "p5,Atribut for ad",
"nol_c6": "p6,postroll",
"nol_ac": "ad"
]
// metaData
let metadata = [
"content" : metaDataContent,
"ad" : metaDataAd,
"static" : ""
] as [String : Any]
// trackEventObject
let trackEventObject = [
"metadata" : metadata,
"event": "playhead",
"playheadPosition": "1",
"type": "ad",
] as [String : Any]
// fire TrackEvent
self.nielsenEventTracker.trackEvent(trackEventObject)
Step 6 : API Call sequence
Use Case 1: Content has no Advertisements
Playlist : single content, no ads.
A Sample API sequence follow this flow:
Playlist | API call TrackEvent | Description |
---|---|---|
1. Video start | event playhead, type : content, metadata : content_metaDataObject, playheadPosition : 1 | 1st call playhead |
2. Video playing .. | event playhead, type : content, metadata : content_metaDataObject, playheadPosition : 2,3,4.. etc | playhead every second |
3. Video ends | event complete, type : content, metadata : content_metaDataObject, playheadPosition : lastPlayheadValue | call complete |
Use Case 2: Content has Advertisements
Playlist : ad preroll - content - ad midroll - content continues - ad postroll.
A Sample API sequence follow this flow:
Playlist | API call TrackEvent | Description |
---|---|---|
1. Ad Preroll start | event playhead, type : ad, metadata : ad_preroll_metaDataObject + content_metaDataObject, playheadPosition : 1 | 1st call playhead |
2. Ad Preroll playing .. | event playhead, type : ad, metadata : ad_preroll_metaDataObject + content_metaDataObject, playheadPosition : 2,3,4.. etc | playhead every second |
3. Ad Preroll ends | event adStop, type : ad, metadata : ad_preroll_metaDataObject + content_metaDataObject, playheadPosition : lastPosition | call adStop at the end of add |
4. Content start | event playhead, type : content, metadata : content_metaDataObject, playheadPosition : 1 | 1st call playhead |
5. Content playing .. | event playhead, type : content, metadata : content_metaDataObject, playheadPosition : 2,3,4.. etc | playhead every second |
6. Content interupted by midroll | event playhead, type : content, metadata : content_metaDataObject, playheadPosition : lastPlayheadValue | last playhead |
7. Ad Midroll start | event playhead, type : ad, metadata : ad_midroll_metaDataObject + content_metaDataObject, playheadPosition : 1 | 1st call playhead |
8. Ad Midroll playing .. | event playhead, type : ad, metadata : ad_midroll_metaDataObject + content_metaDataObject, playheadPosition : 2,3,4.. etc | playhead every second |
9. Ad Midroll ends | event adStop, type : ad, metadata : ad_midroll_metaDataObject + content_metaDataObject, playheadPosition : lastPosition | call adStop at the end of add |
10. Content continues after midroll | event playhead, type : content, metadata : content_metaDataObject, playheadPosition : 1 | 1st call playhead |
11. Content playing .. | event playhead, type : content, metadata : content_metaDataObject, playheadPosition : 2,3,4.. etc | playhead every second |
12. Content ends | event complete, type : content, metadata : content_metaDataObject, playheadPosition : lastPlayheadValue | call complete for content |
13. Ad Postroll start | event playhead, type : ad, metadata : ad_postroll_metaDataObject + content_metaDataObject, playheadPosition : 1 | 1st call playhead |
14. Ad Postroll playing .. | event playhead, type : ad, metadata : ad_postroll_metaDataObject + content_metaDataObject, playheadPosition : 2,3,4.. etc | playhead every second |
15. Ad Postroll ends | event adStop, type : ad, metadata : ad_postroll_metaDataObject + content_metaDataObject, playheadPosition : lastPosition | call adStop at the end of add |
Use Case 3: Advertisement Pool
where there are more ads in each ad pool.
Playlist : ad preroll1 - preroll 2 - content - ad midroll 1 - ad midroll 2 - content continues - ad postroll 1 - ad postroll 2.
Use adldx parametr to assign position of ad in ad pool (starting from 0)
Ad in pool MetaData Example
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")
.put("adldx" : “0” ); // position in ad pool - 0,1,2..
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. Then once the next ad is started the adIdx parameter should be changed and provided - like below
self.data.updateValue("adStop", forKey: "event")
self.data.updateValue("223", forKey: "adldx")
self.nielsenEventTracker.trackEvent(data)
Step 7 : Handling Foreground and Background states
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.
Call API call pause when app is entering Background.
Step 8 : Privacy and Opt-Out
A user can opt-out if they would prefer not to participate in any Nielsen online measurement research.
Users must have access to "About Nielsen Measurement" web page - see below, or have similar text available within the native app.
Include link or text to
- app settings screen
- or to your Privacy Policy / EULA section
- 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/browser/cz/cs/optout.html for more information
SDK will be sending the data pings to census even though SDK is opted out (In earlier releases all the traffic from SDK to census will be ceased). However, all the outgoing pings will have the parameter uoo=true using which backend can ignore this data.
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.
1. Get Url of privacy page
URL for the Nielsen Privacy web page should be retrieved using API call optOutURL
optOutUrlfromSKD = self.nielsenEventTracker!.optOutURL
If the App SDK returns NULL in the optOutURL, handle the exception gracefully and retry later. Example of returned Url is https://priv-policy.imrworldwide.com/priv/mobile/cz/cs/optout.html followed by unique hash.
2. Open URL in webView
Recieved URL should be opened in 'WebView' / External browser. App should provide a UI control like 'close' or 'back' button to close the 'WebView' / External browser.
3. Get current Opt-Out status (voluntarily)
To retrieve the current Opt-Out status of a device, use the optOutStatus method.
let optOutStatusDetected = nielsenEventTracker!.optOutStatus
if returns false = no OptOut, if true = OptOut is active.
Step 9 : Test your player by your self
Guide
- Connect your PC and test device (tablet or phone) via same router.
- PC side: run Proxy sw (like Charles) and get local IP
- Test device: modify Wifi setting to pass throug Proxy IP from add 2
- Test device: run your player, launch video
- 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
https://secure-cert.imrworldwide.com/cgi-bin/gn?prd=dcr&ci=cz-509218&ch=cz-509218_c04_P&asn=defChnAsset&sessionId=OasHSz6TtBLlBK7m8L63h3cEihKCL1553591192
&tl=Ad%2520preroll%2520Renault&prv=1&c6=vc,c04&ca=cz-509218_c04_id_ad1&cg=myProgram
&c13=asid,P9E9DAEAE-BDEE-461B-8263-54CD2DCBDA22&c32=segA,NA&c33=segB,Programov%25C3%25BD%2520typ
&c34=segC,NA&c15=apn,CZ%20demo%20TrackEvent&plugv=&playerv=&sup=1&segment2=-1&segment1=cze
&forward=0&ad=1&cr=4_00_99_D1_00000&c9=devid,&enc=true&c1=nuid,&at=timer&rt=video&c16=sdkv,ai.6.0.0
&c27=cln,15&crs=&lat=&lon=&c29=plid,P9E9DAEAE-BDEE-461B-8263-54CD2DCBDA22&c30=bldv,ai.6.2.0.0_gada&st=dcr
&c7=osgrp,IOS&c8=devgrp,TAB&c10=plt,MBL&c40=adbid,&c14=osver,iOS12_1_4&c26=dmap,1&dd=
&hrd=&wkd=&c35=adrsid,&c36=cref1,9827411&c37=cref2,&c11=agg,1&c12=apv,&c51=adl,15
&c52=noad,1&sd=34&devtypid=iPad5,3&pc=NA&c53=fef,n&c54=oad,&c55=cref3,&c57=adldf,2&ai=id_ad1&c3=st,a
&c64=starttm,1553591199&adid=id_ad1&c58=isLive,false&c59=sesid,mmk4Mnl3tXLhVD7Conqn7sBNMtn4o1553591199
&c61=createtm,1553591214&c63=pipMode,&c60=cvarall,p0%252Cdcrcz~~~~~~st%252Ca~~p4%252CASMEA%2520code%2520for
%2520ad~~p5%252CAtribut%2520for%2520ad~~p6%252Cpreroll&c62=sendTime,1553591214
&c68=bndlid,cz.admosphere.iOSdemo.TrackEvent.Josef&c69=cvw,&nodeTM=&logTM=&c73=phtype,Tablet
&c74=dvcnm,Apple+iPad&c76=adbsnid,&df=-1&uoo=true&c44=progen,&davty=1&si=&c66=mediaurl,&vtoff=0&rnd=1553591214683
Step 10: Provide your app for certification
Once ready please send your application to Nielsen local staff for verification - see Contact list for Czech Republic.
Step 11: 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 4.