Ad targeting
You can use the Yandex Mobile Ads SDK API to add extra user information. Adding context data to the request can significantly enhance the quality of advertising and increase your revenue.
Set up targeting
You can pass user information in the ad request:
- For a banner (inline and sticky), use the
AdRequest
class. - For an interstitial ad, rewarded ad and app open ad, use the
AdRequestConfiguration
class. - For a native ad, use the
NativeAdRequestConfiguration
class. - For an ad feed, use the
FeedAdRequestConfiguration
class.
You can provide the following user information:
Parameter |
Description |
|
User age: a number in string format (for example, "14", "18", and so on) |
|
User gender: "male", "female". You can use the |
|
The user's location as detected by your app. To use the location, you must obtain the user's consent to your app using their location and set |
|
The user's search query in the app. For instance, if the user searched for a car, the parameter might look like "Buy a used car in Moscow" |
|
Keywords from the page the user was viewing. These could be the page's title, parts of its content, tags, and other elements. For a page with a car search, this parameter might look like "Buy a car", "used car", "in Moscow" |
Examples of targeting (Kotlin)
Adaptive inline and sticky banners
val adRequest = AdRequest.Builder()
.setAge("25")
.setGender(Gender.MALE)
.setLocation(Location("provider"))
.setContextQuery("Buy a used car in Moscow")
.setContextTags(listOf("Buy a car", "used car", "in Moscow"))
.build()
loadAd(adRequest)
Interstitial, Rewarded and App Open Ad
val adRequestConfiguration = AdRequestConfiguration.Builder("demo-interstitial-yandex")
.setAge("25")
.setGender(Gender.MALE)
.setLocation(Location("provider"))
.setContextQuery("Buy a used car in Moscow")
.setContextTags(listOf("Buy a car", "used car", "in Moscow"))
.build()
loadAd(adRequestConfiguration)
Native ad
val nativeAdRequestConfiguration = NativeAdRequestConfiguration.Builder("demo-native-yandex")
.setAge("25")
.setGender(Gender.MALE)
.setLocation(Location("provider"))
.setContextQuery("Buy a used car in Moscow")
.setContextTags(listOf("Buy a car", "used car", "in Moscow"))
.build()
nativeAdLoader?.loadAd(nativeAdRequestConfiguration)
Ad feed
val feedAdRequestConfiguration = FeedAdRequestConfiguration.Builder("demo-feed-yandex")
.setAge("25")
.setGender(Gender.MALE)
.setLocation(Location("provider"))
.setContextQuery("Buy a used car in Moscow")
.setContextTags(listOf("Buy a car", "used car", "in Moscow"))
.build()
val feedAd = FeedAd.Builder(context, feedAdRequestConfiguration, feedAdAppearance).build()
feedAd.loadListener = feedAdLoadListener