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
MutableAdRequestclass. - For an interstitial ad, rewarded ad and app open ad, use the
MutableAdRequestConfigurationclass. - For a native ad, use the
MutableNativeAdRequestConfigurationclass.
You can provide the following user information:
|
Parameter |
Description |
|
|
User age: a number in string format (for example, |
|
|
User gender: You can use the |
|
|
The user location as detected by your app. |
|
|
User's search query in the app. For instance, if the user searched for a car, the parameter might look like |
|
|
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 |
Targeting examples (Swift)
Adaptive inline and sticky banners
let adRequest = MutableAdRequest()
adRequest.age = 20
adRequest.gender = kYMAGenderMale
adRequest.location = CLLocation(latitude: 1, longitude: 2)
adRequest.contextQuery = "Buy a used car in Moscow"
adRequest.contextTags = ["Buy a car", "used car", "in Moscow"]
adView.loadAd(with: adRequest)
Interstitial ads, rewarded ads, and app open ads
let adRequest = MutableAdRequestConfiguration(adUnitID: "your_block_id")
adRequest.age = 20
adRequest.gender = kYMAGenderMale
adRequest.location = CLLocation(latitude: 1, longitude: 2)
adRequest.contextQuery = "Buy a used car in Moscow"
adRequest.contextTags = ["Buy a car", "used car", "in Moscow"]
interstitialAdLoader.loadAd(with: adRequest)
Native ads
let adRequest = MutableNativeAdRequestConfiguration(adUnitID: "your_block_id")
adRequest.age = 20
adRequest.gender = kYMAGenderMale
adRequest.location = CLLocation(latitude: 1, longitude: 2)
adRequest.contextQuery = "Buy a used car in Moscow"
adRequest.contextTags = ["Buy a car", "used car", "in Moscow"]
adLoader.loadAd(with: adRequest)