DCR React Native Integration

From Engineering Client Portal

Revision as of 13:37, 2 March 2018 by MarkusMohr (talk | contribs)

Engineering Portal breadcrumbArrow.png Digital breadcrumbArrow.png International breadcrumbArrow.png DCR React Native Integration

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.

This guide will show how to use the Nielsen SDK in React Native applications on Android and iOS devices. We will not go into detail about what React Native is or how to create Apps with this Framework. If you are looking for information on this, please read the React-Native documentation.

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.

Implementation

This guide covers implementation covers

  • the implementation of React-Native bridges for iOS and Android
  • the usage of the exposed Javascript API

Setting up your Environment

iOS

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.

Nielsen App SDK is compatible with Apple iOS versions 9.0 and above.

  • 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 (Not applicable for International (Germany))
  • 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

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


Android

The Java AppSdk.jar library that runs on the Android’s Dalvik Virtual Machine.

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]. Download the latest google-play-services_lib and include it in the App’s project in order to use the App SDK.

  • 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;


Creating React-Native bridges for the Nielsen SDK

iOS

NielsenReactBridge.h

// Copyright <YEAR> <COPYRIGHT HOLDER>
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
// (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

#import <React/RCTBridgeModule.h>

@interface NielsenReactBridge : NSObject <RCTBridgeModule>
@end

NielsenReactBridge.m

// Copyright <YEAR> <COPYRIGHT HOLDER>
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
// (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

static NSString *const TAG = @"NielsenReactBridge";

@interface NielsenReactBridge() <NielsenAppApiDelegate>
@property (strong) NielsenAppApi* nlsSDk;
@end


@implementation NielsenReactBridge
RCT_EXPORT_MODULE();

- (NSArray<NSString *> *)supportedEvents
{
  return @[@"OptOutUrl"];
}

/**
 */
void NLSLog(NSString* tag, NSString* format, ...)
{
  va_list argList;
  va_start(argList, format);
  NSLog(@"%@", [[NSString alloc] initWithFormat:[NSString stringWithFormat:@"[%@]: %@", tag, format] arguments: argList]);
  va_end(argList);
}

/**
 */
RCT_EXPORT_METHOD(init:(NSDictionary *)appInfo)
{
  NLSLog(TAG, @"init called with metadat '%@''", appInfo);

  if (!self.nlsSDk) {
    self.nlsSDk= [[NielsenAppApi alloc] initWithAppInfo:appInfo delegate:self];
  }
}

/**
 */
RCT_EXPORT_METHOD(play:(NSDictionary *)channelInfo)
{
  NLSLog(TAG, @"play called with metadata '%@'", channelInfo);

  if (self.nlsSDk) {
    [self.nlsSDk play:channelInfo];
  }
}

/**
 */
RCT_EXPORT_METHOD(loadMetadata:(NSDictionary *)contentMetaData)
{
  NLSLog(TAG, @"loadMetadata called with '%@'", contentMetaData);

  if (self.nlsSDk) {
    [self.nlsSDk loadMetadata:contentMetaData];
  }
}

/**
 */
RCT_EXPORT_METHOD(setPlayheadPosition:(nonnull NSNumber *)ph)
{
  NLSLog(TAG, @"setHeadPosition called with '%@'",ph);

  if (self.nlsSDk) {
    [self.nlsSDk playheadPosition:[ph longLongValue]];
  }
}

/**
 */
RCT_EXPORT_METHOD(stop)
{
  NLSLog(TAG, @"stop called");

  if (self.nlsSDk) {
    [self.nlsSDk stop];
  }
}

/**
 */
RCT_EXPORT_METHOD(end)
{
  NLSLog(TAG, @"end called");

  if (self.nlsSDk) {
    [self.nlsSDk end];
  }
}

/**
 */
RCT_EXPORT_METHOD(optOutUrl)
{
  [self sendEventWithName:@"OptOutUrl" body:@{@"url": self.nlsSDk.optOutURL}];
}
@end

Android

com/nielsen/app/react/NielsenPackage.java

// Copyright <YEAR> <COPYRIGHT HOLDER>
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
// (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package com.nielsen.app.react;

import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.ReactPackage;
import com.facebook.react.uimanager.ViewManager;
import com.nielsen.app.react.NielsenReactBridge;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 */
public class NielsenPackage implements ReactPackage {

    /**
    */
    @Override
    public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
        List<NativeModule> modules = new ArrayList<>();
        modules.add(new NielsenReactBridge(reactContext));

        return modules;
    }

    /**
    */
    @Override
    public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
        return Collections.emptyList();
    }
}

com/nielsen/app/react/NielsenReactBridge.java

// Copyright <YEAR> <COPYRIGHT HOLDER>
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
// (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
// merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package com.nielsen.app.react;

import android.util.Log;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableMapKeySetIterator;
import com.nielsen.app.sdk.AppSdk;
import com.nielsen.app.sdk.IAppNotifier;
import com.nielsen.app.sdk.AppLaunchMeasurementManager;
import org.json.JSONObject;
import org.json.JSONException;

/**
 * NielsenReactBridge is the class briding between react JS code
 * and the native Nielsen SDK.
 */
public class NielsenReactBridge extends ReactContextBaseJavaModule 
                                implements IAppNotifier, LifecycleEventListener {

    /**
    */
    private static final String NIELSEN_TAG = "NielsenReactBridge";
    private AppSdk mAppSdk = null; // the AppSdk main object

    /**
     * Constructor for the NielsenReactBridge
     * Adds the new instance as LifeCycleEventListener for conttex
     * @param context  The react application context
     */
    public NielsenReactBridge(ReactApplicationContext context) {
        super(context);
        context.addLifecycleEventListener(this);
    }

    /**
     * Implements getName method from ReactContextBaseJavaModule
     * @return  The constant string 'NielsenReactBridge'
     */
    @Override
    public String getName() {
        return "NielsenReactBridge";
    }

    /**
     * Implements getName method from IAppNotifier
     */
    @Override
    public void onAppSdkEvent(long l, int i, String s) {}

    /**
     * Initializes the module for use 
     * @param obj   An instance of ReadableMap (mapped JS object) containing
     *              initialization meta data
     */
    @ReactMethod
    public void init(final ReadableMap obj) {

        Log.d(NIELSEN_TAG, "Called init");

        if (null == mAppSdk) {
            try {
                JSONObject appSdkConfig = readableMapToJSONObject(obj);
                mAppSdk = new AppSdk(getReactApplicationContext(), appSdkConfig, this);
                if (!mAppSdk.isValid())
                {
                    Log.e(NIELSEN_TAG, "SDK Init failed");
                }
            }
            catch(Exception ex) {
            }   
        }
    }

    /**
     * Static method to convert ReadableMap instances to JSONObject instances
     * (used by the Nielsen SDK)
     * @param obj   The ReadableMap instance to be converted
     * @return      An instance of JSONObject containing the mapped JS object
     *              values (if successful, empty otherwise) 
     */
    static private JSONObject readableMapToJSONObject(final ReadableMap obj) {

        JSONObject ret = new JSONObject();

        try {
            ReadableMapKeySetIterator it = obj.keySetIterator();
            while (it.hasNextKey()) {
                String key = it.nextKey();
                ret.put(key, obj.getDynamic(key).asString());
            }
        }
        catch (JSONException ex) {
            Log.e(NIELSEN_TAG, ex.getMessage());
        }

        return ret;
    }

    /**
     * Wrapper for the Nielsen SDK play method. Simply forwards calls 
     * to the SDK.
     * @param obj   ReadableMap instance containing the mapped JS meta
     *              data object, e.g. {channelName: 'channel name here'}
     */
    @ReactMethod
    public void play(final ReadableMap obj) {

        Log.d(NIELSEN_TAG, "Called play " + obj.toString());
        if (null != mAppSdk) {
            JSONObject playObject = readableMapToJSONObject(obj);
            mAppSdk.play(playObject);
        }
    }

    /**
     * Wrapper for the Nielsen SDK loadMetadata method. Simply forwards calls 
     * to the SDK.
     * @param obj   ReadableMap instance containing the mapped JS meta
     *              data object
     */
    @ReactMethod
    public void loadMetadata(final ReadableMap obj) {

        Log.d(NIELSEN_TAG,"Called loadMetadata");
        if (null != mAppSdk) {
            JSONObject contentMetadata = readableMapToJSONObject(obj);
            mAppSdk.loadMetadata(contentMetadata);
        }
    }

    /**
     * Wrapper for the Nielsen SDK setPlayheadPosition method. Simply 
     * forwards calls to the SDK.
     * @param ph    The current playhead position
     */
    @ReactMethod
    public void setPlayheadPosition(final Double ph) {

        Log.d(NIELSEN_TAG,"Called setPlayHeadPosition: " + " " + ph);
        if (null != mAppSdk) {
            mAppSdk.setPlayheadPosition(ph.longValue());
        }
    }

    /**
     * Wrapper for the Nielsen SDK stop method. Simply 
     * forwards calls to the SDK.
     */
    @ReactMethod
    public void stop() {
        Log.d(NIELSEN_TAG, "Called stop");
        if (null != mAppSdk) {
            mAppSdk.stop();
        }
    }

    /**
     * Wrapper for the Nielsen SDK end method. Simply 
     * forwards calls to the SDK.
     */
    @ReactMethod
    public void end() {
        
        Log.d(NIELSEN_TAG,"Called end");
        if (null != mAppSdk) {
            mAppSdk.end();
        }
    }

    /**
     * Wrapper to retrieve the optOutUrl from the Nielsen SDK. 
     * Emits a "OptOutUrl" event with the url as payload.
     * Needs to be catched in JS
     */

    @ReactMethod
    public void optOutUrl() {

        WritableMap params = Arguments.createMap();
        if (null != mAppSdk) {
            params.putString("url", mAppSdk.userOptOutURLString());
        }

        getReactApplicationContext()
        .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
        .emit("OptOutUrl", params);
    }

    /**
     * Implements LifecycleEventListener's onHostResume method.
     * Uses AppLaunchMeasurementManager.appInForeground to notify SDK about
     * app coming to foreground again
     */
    @Override
    public void onHostResume() {

        Log.d(NIELSEN_TAG,"Called onHostResume");
        if (null != mAppSdk) {
            AppLaunchMeasurementManager.appInForeground(getReactApplicationContext());
        }
    }

    /**
     * Implements LifecycleEventListener's onHostPause method.
     * Uses AppLaunchMeasurementManager.appInBackground to notify SDK about
     * app going to background
     */
    @Override
    public void onHostPause() {

        Log.d(NIELSEN_TAG,"Called onHostPause");
        if (null != mAppSdk) {
            AppLaunchMeasurementManager.appInBackground(getReactApplicationContext());
        }
    }

    /**
     * Implements LifecycleEventListener's onHostDestroy method.
     */
    @Override
    public void onHostDestroy() {
        Log.d(NIELSEN_TAG,"Called onHostDestroy");
    }
}

NielsenModule.js

import { NativeModules } from 'react-native'

export default NativeModules.NielsenReactBridge

SDK Initialization

The bridge implementations above allow the usage of one instance of the Nielsen App SDK. The latest version of the Nielsen App SDK allows instantiating multiple instances of the SDK object, which can be used simultaneously without any issue. For more information on this please read the relevant App SDK Guide.


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

  • The appid is provided by the Nielsen Technical Account Manager (TAM). The appid is a GUID data type and is specific to the application.
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.

Italian Clients

  • "it"
Nielsen-specified Yes "it"
nol_devDebug Enables Nielsen console logging. Only required for testing Nielsen-specified Optional "DEBUG"



Sample SDK Initialization Code

    import NielsenModule from './NielsenModule';

    let appInformation = {"appid": "PDA7D5EE6-B1B8-XXXX-XXXX-2A788BCXXXCA",
                          "appversion": "1.0",
                          "appname": "app name here",
                          "sfcode": "it",
                          "nol_devDebug": @"DEBUG"};
   let nielsenInstance = NielsenModule.init(appInformation);

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.

Configure Payload

Configure metadata

Configure metadata 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.

Keys Description Values Required
type type of asset "content" Yes
assetid unique ID assigned to asset custom Yes
program name of program (25 character limit) custom Yes
title name of program (40 character limit) custom Yes
length length of content in seconds seconds (86400 for live stream) 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
adloadtype type of ad load:

"1" Linear – matches TV ad load

"2" Dynamic – Dynamic Ad Insertion (DAI)

"2" - DCR measures content with dynamic ads Yes


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 Required
type type of ad 'preroll', 'midroll', or 'postroll'
assetid unique ID assigned to ad custom

Configure API Calls

Sample API Sequence

A Sample API sequence could follow this flow:

Type Sample code Description
On App Start NielsenModule.loadMetadata(contentMetadata); // contentMetadata Object contains the JSON metadata for the impression
Start of stream NielsenModule.play(channelName); // channelName contains JSON metadata of channel/video name being played
NielsenModule.loadMetadata(contentMetadataObject); // contentMetadataObject contains the JSON metadata for the content being played
Content NielsenModule.playheadPosition(position); // playheadPosition is position of the playhead while the content is being played
End of Stream NielsenModule.end(); // Content playback is completed.

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. play and loadMetadata calls move the SDK instance into this state. In this state, the SDK instance will be able to process the following calls.
    1. playheadPosition – Call this API every one second when playhead position timer is fired.
    2. stop – Call this API when the playback is paused, switches between content and ad (within the same content playback) or encounters interruptions.
    3. end – SDK instance exits from Processing state when this API is called.
  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;

Note: For API Version 5.1 and above, App SDK will fire data pings and continue measurement even after the user has opted out from Nielsen measurement on a device. The data ping will be marked as opted-out ping.

Note: In case of any interruptions during playback due to alarm, calendar, call, flight mode, Wi-Fi toggle, channel change, etc., call stop to stop the measurement.

Sequence of Calls

play

Use play to pass the channel descriptor information through channelName parameter when the user taps the Play button on the player.

   NielsenModule.play(channelInfo);


loadMetadata

   NielsenModule.loadMetadata(contentMetadata);


playheadPosition

   NielsenModule.playheadPosition(playheadPos);


stop

   NielsenModule.stop();


end

When content stop is initiated and content cannot be resumed from the same position (it can only be restarted from the beginning of stream).

   NielsenModule.end();

Privacy and Opt-Out

iOS

iOS Opt-Out Implementation

To opt out, users must have access to "About Nielsen Measurement" page. User can click this page from app settings screen.

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 for the Nielsen Privacy web page should be retrieved from the optOutURL property of the SDK object optOutURL and opened in 'WebView' / External browser.
  • If the App SDK returns NULL in the optOutURL, handle the exception gracefully and retry later.
  • To retrieve the current Opt-Out status of a device, use the optOutStatus method.


The app must provide access to "About Nielsen Measurement" page for the users. 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.

Privacy policy iOS.jpg

  • URL to this web page should be called from SDK and opened in 'WebView' / External browser.
  • If the App SDK returns NULL as Opt-Out URL, handle this case and retry later.
  • To retrieve the current Opt-Out status, use the optOutStatus property from Nielsen's SDK API.
@property (readonly) BOOL optOutStatus;
  • App should provide a UI control like 'close' or 'back' button to close the 'WebView' / External browser.


Users can opt out or opt back into Nielsen Measurement. Opt-Out feature relies on iOS' system setting – "Limit Ad Tracking". The setting can be accessed in the Settings application on any iOS device: Settings → Privacy → Advertising → Limit Ad Tracking.

User is opted out of Nielsen online measurement research when the "Limit Ad Tracking" setting is enabled.

Opt-Out iOS.jpg

Note: For API Version 5.1 and above, App SDK will fire data pings and continue measurement even after the user has opted out from Nielsen measurement on a device. The data ping will be marked as opted-out ping.



Java

Android Opt-Out Implementation

To opt out, users must have access to "About Nielsen Measurement" page. User can click this page from app settings screen.

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.
public String userOptOutURLString()
  • 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 getOptOutStatus() method.
public boolean getOptOutStatus()

Displaying Opt-Out in a WebView

optOutUrl = mAppSdk.userOptOutURLString();
if(optOutUrl !=null)
{
   mWebView = (WebView) findViewById(R.id.webView);
   mWebView.getSettings().setJavaScriptEnabled(true);
   mWebView.getSettings().setBuiltInZoomControls(true);
   mWebView.getSettings().setDisplayZoomControls(false);
   mWebView.getSettings().setLoadWithOverviewMode(true);
   mWebView.getSettings().setUseWideViewPort(true);
   mWebView.setWebViewClient(new MonitorWebView());
   mWebView.setWebChromeClient(new WebChromeClient());
   mWebView.loadUrl(optOutUrl);
}
else
{
   //Handle it gracefully and Retry later
}


The app must provide access to "About Nielsen Measurement" page for the users. 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.

Privacy policy iOS.jpg

Note: When ‘WebView’ / External browser is closed, do not pass the status returned from ‘WebView’ / External browser to the SDK within the app, as the new Opt-Out page will not return any response.

Note: App SDK manages the user’s choice (Opt-Out / Opt-In), the app does not need to manage this status.

Starting from SDK version 5.1.1.18:

  • 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.
  • Current Opt-Out page is now updated to have no hyperlinks for Opt-Out / Opt-In operations. SDK Opt-Out has to be done via

Google Settings → Ads → Opt out of Ads Personalization.

Note: For Amazon devices, see Opt-Out Implementation for Amazon Devices below.

andr-ads.jpg

Note: The App SDK will fire data pings and continue measurement even after the user has opted out from Nielsen measurement on a device. The data ping will be marked as opted-out ping.

Opt-Out Implementation for Amazon Devices

Amazon device users can opt out or opt back into Nielsen Measurement, any time using the device’s setting – 'Limit Ad Tracking' (Interest-based ads).

User is opted out of Nielsen Online Measurement when ‘Limit Ad Tracking’ is enabled.


For devices running on Fire OS 5.1 and above, retrieve the Ad tracking value.

Retrieving Ad tracking Value

ContentResolver cr = getContentResolver();
int limitAdTracking = Secure.getInt(cr, "limit_ad_tracking", 2);
  • Returns limit_ad_tracking value "0" if enabled
  • Returns limit_ad_tracking value "1" if disabled
  • Returns limit_ad_tracking value "2" if ad tracking is not supported (below Fire OS 5.1).

Note: Google Play Services are not needed to retrieve ad tracking state on Amazon devices. Limit Ad Tracking can be accessed through Settings → Apps & Games → Advertising ID.

Going Live

Following Nielsen testing, users need to make one update to the initialization call to ensure that the site is being measured properly.

  1. Debug Logging: Disable logging by deleting {nol_devDebug: 'DEBUG'} from initialization call.
    • Example Production Initialization Call - Refer to the production initialization call below:

Example:

    let appInformation = {
            "appid": "PXXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
            "sfcode": "it"
            // Remove Flag:   "nol_devDebug": "DEBUG"
    };
    NielsenModule.initi(appInformation);