Data Passing

Need to know

As of the 5.0 SDK release, MoPub provides a field for publisher 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 (i.e., targeting based on the content of the app). Additionally, publishers should not send MoPub any keywords that are against the MoPub Privacy Policies.

New in 5.0

  • Personal data passing: The MoPub SDK now exposes an additional keyword API (userDataKeywords) 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 passing: Contextual keywords can continue to be passed via the keywords API.

Passing Keywords

Pass the keywords from your app to MoPub as a comma-separated list in the ad view. Each keyword should be formatted as a key/value pair (e.g. m_age:24). Any characters can be used except & and =.

Banners and interstitials

MPAdView *adView = [[MPAdView alloc] initWithAdUnitId:@"AD_UNIT_ID" size:MOPUB_BANNER_SIZE];
adView.delegate = self;
adView.keywords = @"CONTEXTUAL_KEYWORDS";
adView.userDataKeywords = @"USER_DATA_KEYWORDS";

[adView loadAd];

Rewarded Videos

[MPRewardedVideo keywords:@"CONTEXTUAL_KEYWORDS" userDataKeywords:@"USER_DATA_KEYWORDS" location:nil customerId:@"CUSTOMER_ID" mediationSettings:@[]];

Native ads

MPNativeAdRequestTargeting *targeting = [[MPNativeAdRequestTargeting alloc] init];

targeting.keywords = @"CONTEXTUAL_KEYWORDS";
targeting.userDataKeywords = @"USER_DATA_KEYWORDS";

["YOUR_AD_PLACER" loadAdsForAdUnitID:self.adInfo.ID targeting:targeting]

Passing Location

When personal information may be collected, the MoPub Marketplace and certain ad networks can use your user’s location to send more targeted ads. If your app already has location permissions (based on you obtaining appropriate consent from the end user), the MoPub SDK will automatically attempt to acquire location data for ad requests. Specifically, location data will be obtained over GPS on first usage, and then in 10-minute intervals. If there is no GPS location, the last known location will be preserved.

You can use locationUpdatesEnabled in MoPub.h to opt out of this functionality. The MoPub SDK will never prompt the user for permission if location permissions are not currently granted.

You can also choose to pass the location yourself by passing any CLLocation to MPAdView which will forward what you supply to the location property down to the underlying ad network. Note that, starting in the v5.9.0 of the MoPub SDK, GPS location is prioritized over location data you supply from the app (i.e. when both are available, the MoPub SDK will utilize GPS location).


Using the same key value pairs, target campaigns using the keyword targeting function in the Advanced Targeting dropdown. To target multiple keywords, use AND (e.g. m_gender:m AND m_age:25). If you want to use the OR clause, separate the keywords by a new line.

Frequency Capping ID

In SDK versions 4.9+, MoPub automatically passes a rotating identifier for devices using iOS10 or later and have elected to limit ad tracking. This identifier is used solely to continue to provide MoPub-internal frequency capping, while respecting the change in Apple’s IDFA practices. If you wish to disable this feature, follow the instructions below.

You can use frequencyCappingIdUsageEnabled in MoPub.h to opt out of this functionality.

Best Practices

When in doubt, you can always call [[MoPub sharedInstance] canCollectPersonalInfo] 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, and you must specify the correct iTunes URL or Android package name in the MoPub UI for both the app and the line for which you want to track conversions. 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.)

Import the MPAdConversionTracker.h file in your application delegate, and place the following line in -application:didFinishLaunchingWithOptions:

[[MPAdConversionTracker sharedConversionTracker]

replacing “" with your own.

Last updated November 05, 2019

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.

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