---
metadata:
  - name: generator
    content: Diplodoc Platform v5.57.3
alternate:
  - https://boost.yandex.com/doc/en/ad-monetization/dev/android7/target.md
  - https://boost.yandex.com/doc/ru/ad-monetization/dev/android7/target.md
  - href: en/ad-monetization/dev/android7/target.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
---
> **Documentation Index:** Fetch the complete configuration index at https://boost.yandex.com/doc/en/llms.txt

<!--
Используется в Boost: boost/en/ad-monetization/dev/android
-->

# 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 {#setup}

You can pass user information in the ad request: 

- For a banner ([inline](https://boost.yandex.com/doc/en/ad-monetization/dev/android7/adaptive-inline-banner.md) and [sticky](https://boost.yandex.com/doc/en/ad-monetization/dev/android7/adaptive-sticky-banner.md)), use the `AdRequest` class.
- For an [interstitial ad](https://boost.yandex.com/doc/en/ad-monetization/dev/android7/interstitial.md), [rewarded ad](https://boost.yandex.com/doc/en/ad-monetization/dev/android7/rewarded.md), or [app open ad](https://boost.yandex.com/doc/en/ad-monetization/dev/android7/app-open-ad.md), use `AdRequestConfiguration`.
- For a [native ad](https://boost.yandex.com/doc/en/ad-monetization/dev/android7/native.md), use the `NativeAdRequestConfiguration` class.
- For an [ad feed](https://boost.yandex.com/doc/en/ad-monetization/dev/android7/feed-ad.md), use the `FeedAdRequestConfiguration` class.

You can provide the following user information:

#|
|| **Parameter** | **Description** || 
|| `age` | The user's age in string format, for example: `"14"`, `"18"`. || 
|| `gender` | The user's gender: `male`, `female`. 

You can use the `Gender` object to get a valid string. || 
|| `location` | The user's location as detected by your app. 

Before setting this parameter, you must obtain user consent for location access and call `MobileAds.setLocationConsent(true)` in the SDK. ||
|| `contextQuery` | The user's search query in the app. 

For instance, if the user searched for a car, this parameter might look like this: `"Buy a used car in Moscow"`. ||
|| `contextTags` | The keywords from the page the user was viewing. These can 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) {#examples-kotlin}

#### Adaptive inline and sticky banners

```kotlin
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 ads, rewarded ads, and app open ads

```kotlin
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 ads

```kotlin
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

```kotlin
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
```
