Passing Location & Keywords - iOS
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, the MoPub SDK will automatically attempt to acquire location data for ad requests.
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. This is boolean value which needs to be set from true to false.
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 demand source. If you choose to pass the location yourself then the MoPub SDK does not alter it .
Keywords allow you to target certain ad requests with user data. This feature is often used to differentiate a specific user demographic or users on different app versions.
You can pass keywords from your app to MoPub as a comma-separated list in the ad view. They should be in the format of key value pairs (e.g. m_age:24). You can use any characters except for “&” and “=”. Spaces are allowed, and special characters are discouraged.
MPAdView *adView = [[MPAdView alloc] initWithAdUnitId:@"AD_UNIT_ID" size:MOPUB_BANNER_SIZE]; adView.delegate = self; adView.keywords = @"m_age:24,m_gender:m,m_marital:single"; [adView loadAd];
For native ads, you can pass in keywords using the MPNativeAdRequestTargeting class.
MoPub recommends that the publishers use the standard keywords listed below for passing gender and age data. Applying this standard for passing first party data will result in targeted ads from the MoPub Marketplace and certain ad networks. Passing data/keywords to the exchange allows bidders/advertisers to make better decisions on what creatives to serve and to value the inventory appropriately. This enables publishers to monetize their inventory in a more user-friendly and relevant way while enabling MoPub to run open, transparent, and data-driven exchange.
For gender you would pass:
Example: m_gender:m for male or m_gender:f for female
For age you would pass:
Please reference ‘Advanced Line Item Targeting’ for details on how to target line items to keyword value pairs being passed .
When using keyword targeting in the line items, the maximum length of the keywords is 10K characters.