---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://ads.yandex.com/helpcenter/en/dev/ios7/target.md
  - https://ads.yandex.com/helpcenter/ru/dev/ios7/target.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ads.yandex.com/helpcenter/en/llms.txt

# 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](https://ads.yandex.com/helpcenter/en/dev/ios7/adaptive-inline-banner.md) and [sticky](https://ads.yandex.com/helpcenter/en/dev/ios7/adaptive-sticky-banner.md)), use the `MutableAdRequest` class.
- For an [interstitial ad](https://ads.yandex.com/helpcenter/en/dev/ios7/interstitial.md), [rewarded ad](https://ads.yandex.com/helpcenter/en/dev/ios7/rewarded.md) and [app open ad](https://ads.yandex.com/helpcenter/en/dev/ios7/app-open-ad.md), use the `MutableAdRequestConfiguration` class.
- For a [native ad](https://ads.yandex.com/helpcenter/en/dev/ios7/native.md), use the `MutableNativeAdRequestConfiguration` class.

You can provide the following user information:

#|
|| **Parameter** | **Description** ||
|| `age` | User age: a number in string format (for example, `"14"`, `"18"`, and so on). ||
|| `gender` | User gender: `male`, `female`.

You can use the `kYMAGenderFemale` and `kYMAGenderMale` constants to get a valid string. ||
|| `location` | The user location as detected by your app. ||
|| `contextQuery` | 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"`. ||
|| `contextTags` | 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"`. ||
|#

## Targeting examples (Swift) {#examples-swift}

#### Adaptive inline and sticky banners

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

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

```swift
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)
```
