Passing Location & Keywords - Android


Passing Latitude and Longitude

The MoPub Marketplace and certain ad networks can use your user’s location to send more targeted ads. Our SDK will automatically pass over latitude and longitude coordinates if available in the app and enabled in the SDK. By default the location precision is 6 decimal points.

If you use location in your app, but would like to disable location passing to MoPub, use the location methods on the `com.mopub.comon.MoPub` class:

   package org.myapp
   
   import com.mopub.common.MoPub;

   class MyActivity extends Activity {

       @Override
       public void onCreate {
           ...
           MoPub.setLocationAwareness(MoPub.LocationAwareness.DISABLED);
           ...
       }
   }

Passing Keywords

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.

For banner and interstitial ads, pass the keywords from your app to MoPub as a comma-separated list in the ad view. They should be formatted as key/value pairs (e.g. m_age:24). You can use any character except “&” and “=”. Spaces are allowed, and special characters are discouraged.

MoPubView moPubView = (MoPubView) findViewById(R.id.mopubview);
moPubView.setAdUnitId("AD_UNIT_ID");
moPubView.setKeywords("m_age:24,m_gender:m,m_marital:single");
moPubView.loadAd();

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:

Example: m_age:25

Please reference ‘ Advanced Line Item Targeting ’ for details on how to target line items to keyword value pairs being passed.

Note: For native ads, you can pass in keywords using the RequestParameters class.

Updated: March 2017