Template:Android Privacy and Opt-Out
From Engineering Client Portal
Privacy and Opt-Out
There are two primary methods for implementing user Opt-out preferences:
- OS-level Opt-out - managed by Opt out of Ads Personalization setting on device (preferred approach).
- Legacy Opt-out - Direct call to SDK; used only for older versions of Nielsen Android SDK versions (< 5.1.1.18)
Special Note Regarding Apps in the Kids Category
If you are building an app that will be listed in the Kids Category:
- Ensure that you are using the NoID version of the Nielsen SDK Framework.
- Immediately following the initialization of the Nielsen SDK ensure you execute the Opt out command:
appSdk.userOptOut("nielsenappsdk://1"); // User opt-out
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.
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
- Opt-out if the WebView URL =
- Pass the detected URL to the userOptOut() function
- Example:
appSdk.userOptOut("nielsenappsdk://1"); // User opt-out
- Example:
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/us/en/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);
}