---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://ads.yandex.com/helpcenter/en/dev/ios/target.md
  - https://ads.yandex.com/helpcenter/ru/dev/ios/target.md
  - https://ads.yandex.com/helpcenter/zh/dev/ios/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

Pass user information using `AdTargeting` when you create an `AdRequest`.

You can provide the following user information:

#|
|| **Parameter** | **Description** ||
|| `age` | User age as a number. ||
|| `gender` | User gender: `Gender.male`, `Gender.female`. ||
|| `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}

#### All ad formats

```swift
let targeting = AdTargeting(
    age: 20,
    gender: .male,
    location: CLLocation(latitude: 1, longitude: 2),
    contextQuery: "Buy a used car in Moscow",
    contextTags: ["Buy a car", "used car", "in Moscow"]
)
let request = AdRequest(adUnitID: "your_block_id", targeting: targeting)
```

#### Adaptive inline and sticky banners

```swift
let request = AdRequest(adUnitID: "your_block_id", targeting: targeting)
bannerAdView.loadAd(with: request)
```

#### Interstitial ads, rewarded ads, and app open ads

```swift
let request = AdRequest(adUnitID: "your_block_id", targeting: targeting)
interstitialAdLoader.loadAd(with: request) { result in ... }
```

#### Native ads

```swift
let request = AdRequest(adUnitID: "your_block_id", targeting: targeting)
let options = NativeAdOptions()
adLoader.loadAd(with: request, options: options) { result in ... }
```
