Template

Difference between revisions of "Android Privacy and Opt-Out"

From Engineering Client Portal

(Legacy Opt Out example code)
(Privacy and Opt-Out)
Line 2: Line 2:
 
There are two primary methods for implementing user Opt-out preferences:
 
There are two primary methods for implementing user Opt-out preferences:
 
# '''[[#OS-level_Opt-out|OS-level Opt-out]]''' - managed by ''Opt out of Ads Personalization'' setting on device ('''preferred approach''').
 
# '''[[#OS-level_Opt-out|OS-level 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.
+
# '''[[#User Choice|User Choice]]''' - Direct call to SDK. Can be used without Google Play Services or when using the noAd version of the SDK.
  
 
=== Special Note Regarding Apps in the '''Kids Category''' ===
 
=== Special Note Regarding Apps in the '''Kids Category''' ===
Line 15: Line 15:
 
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.
 
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 Example  ====
+
=== User Choice ===
 +
The ''User Choice'' 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 User's Choice 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 = <code>nielsenappsdk://1</code>
 +
** Opt-in if the WebView URL = <code>nielsenappsdk://0</code>
 +
* Pass the detected URL to the [[userOptOut()]] function
 +
** Example: <syntaxhighlight lang=java>appSdk.userOptOut("nielsenappsdk://1"); // User opt-out</syntaxhighlight>
 +
 
 +
==== OptOut Example Code ====
 
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.
 
The below code is an AndroidX example of displaying the Nielsen Privacy page to the user.
 
<syntaxhighlight lang="java">
 
<syntaxhighlight lang="java">
Line 28: Line 41:
 
         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 43: Line 55:
 
                 onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());
 
                 onReceivedError(view, rerr.getErrorCode(), rerr.getDescription().toString(), req.getUrl().toString());
 
             }
 
             }
 +
 +
// Uncomment below code if you are using User Choice.  This will receive the user's selection
 +
// From the custom User_Choice opt out page.  Only required for non-ad framework or no-id builds
 +
// of the Nielsen SDK
 +
/* 
 +
            @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;
 +
            }
 +
*/
 
         });
 
         });
 
        NielsenInit nielsenInit = new NielsenInit();      // Initializing the NielsenSDK
 
        appSdk = nielsenInit.initAppSdk(getApplicationContext(), this);    //Create Instance
 
 
         String url = appSdk.userOptOutURLString();  // Request Optout URL from NielsenSDK
 
         String url = appSdk.userOptOutURLString();  // Request Optout URL from NielsenSDK
 
         webView.loadUrl(url);                        //Display to the user in a Webview
 
         webView.loadUrl(url);                        //Display to the user in a Webview
 
     }
 
     }
</syntaxhighlight>
+
    @Override
<br>
+
    public void onBackPressed() {
 
+
        super.onBackPressed();
=== User Choice ===
+
        mSdkInterface.getSDK(appSdk);
The ''User Choice'' method is only necessary when the host application does not leverage Google Play Services.
+
    }
 
+
    @Override
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.
+
    protected void onDestroy() {
<br>
+
        super.onDestroy();
==== The legacy opt-out method works as follows: ====
+
        if (appSdk != null)
* Get the current Nielsen opt-out URL via [[userOptOutURLString()]]
+
        {
* Display a WebView element whose loadUrl is set to the value obtained from [[userOptOutURLString()]]
+
            appSdk.close();
* Detect if the WebView URL changes to a special URL that indicates Opt-in, or Opt-out and close the WebView
+
            appSdk = null;
** Opt-out if the WebView URL = <code>nielsenappsdk://1</code>
+
        }
** Opt-in if the WebView URL = <code>nielsenappsdk://0</code>
 
* Pass the detected URL to the [[userOptOut()]] function
 
** Example: <syntaxhighlight lang=java>appSdk.userOptOut("nielsenappsdk://1"); // User opt-out</syntaxhighlight>
 
 
 
==== Legacy Opt Out example code ====
 
<syntaxhighlight lang="java">
 
private class MonitorWebView extends WebViewClient
 
{
 
  private static final String NIELSEN_URL_OPT_OUT = "nielsenappsdk://1";
 
  private static final String NIELSEN_URL_OPT_IN = "nielsenappsdk://0";
 
 
  @Override
 
  public boolean shouldOverrideUrlLoading(WebView view, String url)
 
  {
 
    if (NIELSEN_URL_OPT_OUT.equals(url)
 
      || NIELSEN_URL_OPT_IN.equals(url))
 
    {
 
      // Get AppSdk instance from the host
 
      AppSdk appSdk = HostApp.getAppSdk();
 
      // Send the URL to the AppSdk instance
 
      appSdk.userOptOut(url);
 
      return true;
 
 
     }
 
     }
    return false;
 
  }
 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
<br>
  
 
=== Retrieve current Opt-Out preference ===
 
=== 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,
+
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. <code>appSdk.getOptOutStatus()</code>
  
 
=== Required Privacy Links ===
 
=== Required Privacy Links ===
Line 99: Line 101:
 
In addition, the following text must be included in your app store description.
 
In addition, the following text must be included in your app store description.
 
<blockquote>
 
<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>
+
'''"Please note: This app features Nielsen’s proprietary measurement software which contributes to market research, like Nielsen’s TV Ratings. Please see https://www.nielsen.com/us/en/legal/privacy-statement/digital-measurement/ for more information"'''</blockquote>
 
 
<br>
 

Revision as of 20:56, 8 July 2021

Privacy and Opt-Out

There are two primary methods for implementing user Opt-out preferences:

  1. OS-level Opt-out - managed by Opt out of Ads Personalization setting on device (preferred approach).
  2. User Choice - Direct call to SDK. Can be used without Google Play Services or when using the noAd version of the SDK.

Special Note Regarding Apps in the 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

OS-level Opt-out

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.

User Choice

The User Choice 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 User's Choice 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
      

OptOut Example Code

The below code is an AndroidX 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());
            }

// Uncomment below code if you are using User Choice.  This will receive the user's selection
// From the custom User_Choice opt out page.  Only required for non-ad framework or no-id builds
// of the Nielsen SDK
/*  
            @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 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. appSdk.getOptOutStatus()

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 https://www.nielsen.com/us/en/legal/privacy-statement/digital-measurement/ for more information"