Template

Android Privacy and Opt-Out: Difference between revisions

From Engineering Client Portal

 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Privacy and Opt-Out ==
== Privacy and Opt-Out ==
There are two primary methods for implementing user Opt-out preferences:
There are currently 3 flavors of the Nielsen SDK:
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').
# '''[[#Global_Android_SDK_Opt-out|Global Android SDK Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services.
# '''[[#Global_Android_SDK_No_Ad_Framework_Optout|Global Android SDK No Ad Framework Optout]]''' - Direct call to SDK. Can be used without Google Play Services or when using the noAd version of the SDK.
# '''[[#Global_Android_SDK_No_ID_Optout_.28Kids_Category.29|Global Android SDK No ID Optout]]''' - Direct call to SDK. Should be used for Kids Category.


=== Special Note Regarding Apps in the '''Kids Category''' ===
=== Global Android SDK Opt-out ===
If you are building an app that will be listed in the Kids Category:
''OS-level Opt-out'' method available on Nielsen Android when the [https://developers.google.com/android/guides/setup Google Play services APIs] have been setup in your project.
#  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:
<syntaxhighlight lang=java>appSdk.userOptOut("nielsenappsdk://1");  // User opt-out</syntaxhighlight>


=== OS-level Opt-out ===
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''' setting is ''enabled''. As a publisher, you cannot override this setting.
''OS-level Opt-out'' method available on Nielsen Android.


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"'' setting is ''enabled''. As a publisher, you cannot override this setting.
==== Webview Element ====
It is a requirement to display a WebView element whose loadUrl is set to the value obtained from optOutURL.
If using the Global Android SDK, this optOutURL informs the user how to deactivate/activate “Out of Ads Personalization”.


=== User Choice ===
If you are implementing on Android TV or Fire TV here are your Opt Out verbiage options : https://engineeringportal.nielsen.com/docs/DCR_Video_%26_Static_CTV_Device_SDK_Privacy
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.


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.
==== Retrieve current Opt-Out preference ====
Whether the user is opted out via OS-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. <code>appSdk.getOptOutStatus()</code>


==== The legacy opt-out method works as follows: ====
=== Global Android SDK No Ad Framework Optout ===
The ''No Ad Framework Optout'' can be used when the host application does not leverage Google Play Services such as when using the noAd version or the NoID version.
<blockquote>
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.</blockquote>
 
==== The No Ad Framework Optout method works as follows: ====
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]
Line 29: Line 33:
** Example: <syntaxhighlight lang=java>appSdk.userOptOut("nielsenappsdk://1");  // User opt-out</syntaxhighlight>
** Example: <syntaxhighlight lang=java>appSdk.userOptOut("nielsenappsdk://1");  // User opt-out</syntaxhighlight>


==== Legacy Opt Out example code ====
=== Global Android SDK No ID Optout (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 call the userOptOut API with Opt out selection:
<syntaxhighlight lang=java>appSdk.userOptOut("nielsenappsdk://1");  // User opt-out</syntaxhighlight>
 
== OptOut Example Code ==
Below you will find some sample code for the:
* [[#Global OptOut Example|Global Android SDK]] - managed by Opt out of Ads Personalization setting on device '''(preferred approach)'''.
* [[#No_Ad_Framework_Optout_Sample_Code|Global Android noAd Framework]] - Use if Google Play APIs are unavailable or running noAd version.
*  It is currently not required to display an OptOut page for the NoID/Kids Build of the SDK.
===<span id="Global OptOut Example"></span>Global OptOut Example ===
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.  Please see the next section if using the No Ad Framework build
<syntaxhighlight lang="java">
<syntaxhighlight lang="java">
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {


WebView webView;
    WebView webView;
AppSdk appSdk;
    AppSdk appSdk;


  private static final String NIELSEN_URL_OPT_OUT = "nielsenappsdk://1";
    @Override
  private static final String NIELSEN_URL_OPT_IN = "nielsenappsdk://0";
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//  Within your app you would provide your User the option to Opt Out.
        setContentView(R.layout.activity_optout);
//  Perhaps via a toggle or button
        webView = (WebView) findViewById(R.id.webView);
//  This is separate from Limit Ad Tracking
        webView.getSettings().setJavaScriptEnabled(true);


      let urlStr = navigationAction.request.url?.absoluteString
        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());
            }


         if(urlStr == NIELSEN_URL_OPT_OUT || urlStr == NIELSEN_URL_OPT_IN){
        });
             let appApi = self.nielsenApi
        String url = appSdk.userOptOutURLString();  // Request Optout URL from NielsenSDK
             appApi?.userOptOut(urlStr)
        webView.loadUrl(url);                        //Display to the user in a Webview
    }
    @Override
    public void onBackPressed() {
        super.onBackPressed();
        mSdkInterface.getSDK(appSdk);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
         if (appSdk != null)
        {
             appSdk.close();
             appSdk = null;
        }
    }
}
}
</syntaxhighlight>
</syntaxhighlight>
<br>


=== Retrieve current Opt-Out preference ===
===<span id="No Ad Framework Optout Sample Code"></span>No Ad Framework Optout Sample Code ===
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,
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user with the No Ad Framework SDK Build.
 
=== 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.
<blockquote>
'''"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"'''</blockquote>
==== Webview Example  ====
The below code is an example of displaying the Nielsen Privacy page to the user.
<syntaxhighlight lang="java">
<syntaxhighlight lang="java">
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {
public class OptOutActivity extends AppCompatActivity implements IAppNotifier {
Line 73: Line 107:
         setContentView(R.layout.activity_optout);
         setContentView(R.layout.activity_optout);
         webView = (WebView) findViewById(R.id.webView);
         webView = (WebView) findViewById(R.id.webView);
         webView.getSettings().setJavaScriptEnabled(true);
         webView.getSettings().setJavaScriptEnabled(true);


Line 88: Line 121:
                 onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());
                 onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());
             }
             }
 
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                if(url.contains("nielsen")){
                    // If url value = "nielsenappsdk://1 it means the user selected Opt Out
                    // If url value = "nielsenappsdk://0" it means the user selected Opt-In
                    appSdk.userOptOut(url);
                }
                return true;
            }
         });
         });
 
         String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK
         NielsenInit nielsenInit = new NielsenInit();
         webView.loadUrl(url);                        //Display to the user in a Webview
         appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);
    }
         //Getting the optPut URL from eventTracker
    @Override
         String url = appSdk.userOptOutURLString();
    public void onBackPressed() {
         webView.loadUrl(url);
        super.onBackPressed();
         mSdkInterface.getSDK(appSdk);
    }
    @Override
    protected void onDestroy() {
         super.onDestroy();
         if (appSdk != null)
        {
            appSdk.close();
            appSdk = null;
        }
     }
     }
}
</syntaxhighlight>
</syntaxhighlight>
<br>
 
== Retrieve current Opt-Out preference ==
Whether the user is opted out via OS-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. <code>appSdk.getOptOutStatus()</code>
 
== Going Live ==
Following Nielsen testing, you will need to:
 
# '''Disable Debug Logging''': Disable logging by deleting <code>{nol_devDebug: 'DEBUG'}</code> from initialization call.
# '''Notify Nielsen''': Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.

Latest revision as of 18:27, 4 April 2023

Privacy and Opt-Out

There are currently 3 flavors of the Nielsen SDK:

  1. Global Android SDK Opt-out - managed by Opt out of Ads Personalization setting on device (preferred approach).
  2. Global Android SDK No Ad Framework Optout - Direct call to SDK. Can be used without Google Play Services or when using the noAd version of the SDK.
  3. Global Android SDK No ID Optout - Direct call to SDK. Should be used for Kids Category.

Global Android SDK Opt-out

OS-level Opt-out method available on Nielsen Android when the Google Play services APIs have been setup in your project.

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 setting is enabled. As a publisher, you cannot override this setting.

Webview Element

It is a requirement to display a WebView element whose loadUrl is set to the value obtained from optOutURL. If using the Global Android SDK, this optOutURL informs the user how to deactivate/activate “Out of Ads Personalization”.

If you are implementing on Android TV or Fire TV here are your Opt Out verbiage options : https://engineeringportal.nielsen.com/docs/DCR_Video_%26_Static_CTV_Device_SDK_Privacy

Retrieve current Opt-Out preference

Whether the user is opted out via OS-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. appSdk.getOptOutStatus()

Global Android SDK No Ad Framework Optout

The No Ad Framework Optout can be used when the host application does not leverage Google Play Services such as when using the noAd version or the NoID version.

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 No Ad Framework Optout 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
      

Global Android SDK No ID Optout (Kids_Category)

If you are building an app that will be listed in the Kids Category:

  1. Ensure that you are using the NoID version of the Nielsen SDK Framework.
  2. Immediately following the initialization of the Nielsen SDK ensure you call the userOptOut API with Opt out selection:
appSdk.userOptOut("nielsenappsdk://1");  // User opt-out

OptOut Example Code

Below you will find some sample code for the:

  • Global Android SDK - managed by Opt out of Ads Personalization setting on device (preferred approach).
  • Global Android noAd Framework - Use if Google Play APIs are unavailable or running noAd version.
  • It is currently not required to display an OptOut page for the NoID/Kids Build of the SDK.

Global OptOut Example

The below code is an AndroidX example of displaying the Nielsen Privacy page to the user. Please see the next section if using the No Ad Framework build

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());
            }

        });
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK
        webView.loadUrl(url);                         //Display to the user in a Webview
    }
    @Override
    public void onBackPressed() {
        super.onBackPressed();
        mSdkInterface.getSDK(appSdk);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (appSdk != null)
        {
            appSdk.close();
            appSdk = null;
        }
    }
}


No Ad Framework Optout Sample Code

The below code is an AndroidX example of displaying the Nielsen Privacy page to the user with the No Ad Framework SDK Build.

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());
            }

  
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {

                if(url.contains("nielsen")){
                    // If url value = "nielsenappsdk://1 it means the user selected Opt Out
                    // If url value = "nielsenappsdk://0" it means the user selected Opt-In
                    appSdk.userOptOut(url);
                }
                return true;
            }

        });
        String url = appSdk.userOptOutURLString();   // Request Optout URL from NielsenSDK
        webView.loadUrl(url);                         //Display to the user in a Webview
    }
    @Override
    public void onBackPressed() {
        super.onBackPressed();
        mSdkInterface.getSDK(appSdk);
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (appSdk != null)
        {
            appSdk.close();
            appSdk = null;
        }
    }
}

Retrieve current Opt-Out preference

Whether the user is opted out via OS-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. appSdk.getOptOutStatus()

Going Live

Following Nielsen testing, you will need to:

  1. Disable Debug Logging: Disable logging by deleting {nol_devDebug: 'DEBUG'} from initialization call.
  2. Notify Nielsen: Once you are ready to go live, let us know so we can enable you for reporting. We will not be able to collect or report data prior to receiving notification from you.