Data Passing

As of the 5.0 SDK release, MoPub provides an option for publishers to send personal data. Publisher partners must send any demographic or interest-based targeting data in the fields designated for such data, as described below.

Publisher partners must not include any personal data, including demographic or interest-based targeting data, in any fields intended for contextual targeting (that is, targeting based on the content of the app). Additionally, publishers must not send MoPub any keywords that are against the MoPub Privacy Policies.

Passing Personal and Non-Personal Data

  • Personal data: As of the 5.0 SDK release, the MoPub SDK exposes an additional keyword API (setUserDataKeywords()) for publishers to send personal data. Publisher partners must send any demographic or interest-based targeting data (m_age:24) in this field.

  • Non-personal data: You can continue to pass contextual keywords via the setKeywords() API.

Passing Keywords

Pass the keywords from your app to MoPub as a comma-separated list in the ad view as described below.


  • Enter keywords as key-value pairs. A key-value pair is a set of two linked data items: the first is a key, which is a unique identifier for the item of data, and the second item is the value. Each pair is denoted as key:value. Here is an example of a key-value pair for keywords: m_age:24.

  • Enter each key-value pair as its own String, and each String must be comma-separated.

Official (Reserved) Keywords

Age, gender, and year of birth are the only three values for which MoPub has assigned official keywords. Use the API for user data keywords (setUserDataKeywords()) to pass these three fields.

  • m_age: use to pass age

  • m_gender: use to pass gender

  • m_yob: use to pass year of birth

For any other keywords or data, you may pass them for your business use (such as line-item targeting). The MoPub ad server will not attempt to extract meaningful data from them as a result.


  • You can use any characters except & and =.

  • Keep to a maximum length of 10K characters.


  • To target multiple keywords, use AND. For example: m_gender:m AND m_age:25

  • To use the OR clause, separate the keywords by a new line. For example:

  • To negatively target a property, put a - in front of the keyword. For example: -m_age:25

  • To target a set of values for one keyword, pass each value with the keyword individually.

    For example, this only matches line items that target all three values–apple, banana, orange:

    fruit:apple AND fruit:banana AND fruit:orange

  • To negatively target a set of values for one keyword, use the AND clause.

    For example, here we exclude a line item from being served when the ad request contains the keyword ‘fruit’ with the values set to ‘apple’, ‘bananas’, or ‘oranges’:

    -fruit:apple AND -fruit:banana AND -fruit:oranges

  • Targeting a range is not supported at this time. If you pass a lower-bound and an upper-bound m_age value (for example, m_age:28 OR m_age:29) to the keywords field, MoPub only calculates based on the first m_age that we see.

Banners and Interstitials

MoPubView moPubView;


Rewarded Ads

import com.mopub.mobileads.MoPubRewardedAdManager.RequestParameters;

                        new RequestParameters("CONTEXTUAL_KEYWORDS", "USER_DATA_KEYWORDS", "LOCATION", "CUSTOMER_ID"));

Native Ads

import com.mopub.nativeads.RequestParameters;

RequestParameters mRequestParameters;

mRequestParameters = new RequestParameters.Builder()

"YOUR_AD_ADAPTER".loadAds("AD_UNIT_ID", mRequestParameters);

Passing Location

When personal information may be collected, MoPub Marketplace and some ad networks can use your user’s location to send more targeted ads. If your app already has location permissions (based on your obtaining appropriate consent from the end user), the MoPub SDK automatically attempts to acquire location data for ad requests. Our SDK automatically passes latitude and longitude coordinates if they are available in the app and enabled in the SDK. Specifically, location data is obtained over GPS on first use, and then in 10-minute intervals. If there is no GPS location, the last known location is preserved. Additionally, starting with v5.9.0 of the MoPub SDK, GPS location is prioritized over location data you supply from the app (that is, when both are available, the MoPub SDK uses GPS location).

If you use location in your app, but want to disable location passing to MoPub, you can use the following:



Using the same key-value pairs described in the Passing Keywords section, target campaigns using the keyword targeting function in the Advanced Targeting dropdown.

Best Practices

When in doubt, you can always call MoPub.canCollectPersonalInformation() to determine if you should be processing any personal data. If you are using MoPub mediation, adapters have already been modified to let the mediated SDKs know whether they, too, can collect and process users’ personal data.

User Targeting

When you set up line items to serve ads, you can target users whose devices do or do not already have specific apps installed. These must be apps that you own. We continue to support app targeting for users who have provided consent in the European Economic Area, United Kingdom, and Switzerland. To leverage this capability, you must select this option in the UI, and add the following code to your SDK integration. (To comply with GDPR, we will not have information about users’ apps for users who have not provided their consent.)

In your main Activity class, place the following snippet in your onCreate() method:

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {

    //.... other initialization

    // Installed tracking call
    new MoPubConversionTracker().reportAppOpen(this);

This tracking network event only happens once. A preference variable is stored so that the application doesn’t make additional network calls on later app starts.

Last updated August 28, 2021

TWITTER, MOPUB, and the Bird logo are trademarks of Twitter, Inc. or its affiliates. All third party logos and trademarks included are the property of their respective owners.

© 2021 MoPub (a division of Twitter, Inc.)