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

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

# 广告定位

您可以使用 Yandex Mobile Ads SDK API 添加额外的用户信息。 向请求中添加上下文数据可显著提升广告质量进而增加收入。

## 设置定位 {#setup}

您可以在广告请求中传递用户信息：

- 对于横幅（[内联](https://ads.yandex.com/helpcenter/zh/dev/compose-multiplatform/adaptive-inline-banner.md)和[粘性](https://ads.yandex.com/helpcenter/zh/dev/compose-multiplatform/adaptive-sticky-banner.md)），使用 `AdRequest` 类与 `targeting` 字段。
- 对于[插屏广告](https://ads.yandex.com/helpcenter/zh/dev/compose-multiplatform/interstitial.md)、[激励广告](https://ads.yandex.com/helpcenter/zh/dev/compose-multiplatform/rewarded.md)或[开屏广告](https://ads.yandex.com/helpcenter/zh/dev/compose-multiplatform/app-open-ad.md)，在调用相应的加载器时使用同一个 `AdRequest` 类及其 `targeting` 字段。

您可以提供以下用户信息：

#|
|| **参数** | **描述** ||
|| `age` | 用户年龄，作为字符串进行传递（例如，`"14"`、`"18"` 等）。 ||
|| `gender` | 用户性别。 可能的值：`male` 或 `female`。 ||
|| `location` | 应用检测到的用户位置，使用 `AdLocation` 类进行传递。

要使用位置数据，您必须获得用户的同意，然后在 SDK 中通过 `YandexAds.setLocationTracking(true)` 启用位置信号。 ||
|| `contextQuery` | 用户在应用中的搜索查询。

例如，如果用户搜索汽车，此参数可能如下：`“在莫斯科购买二手车”`。 ||
|| `contextTags` | 用户正在查看的页面中的关键词。 可能是页面的标题、页面的部分内容、标签及其他元素。

对于包含汽车搜索的页面，此参数可能为 `“购买汽车”`、`“二手车”`、`“在莫斯科”`。 ||
|#


## 定位示例 {#examples}

#### 自适应内联和粘性横幅

```kotlin
val adRequest = AdRequest(
    adUnitId = "R-M-XXXXXX-Y",
    targeting = AdTargeting(
        age = "20",
        contextQuery = "context-query",
        contextTags = listOf("context-tag"),
        gender = "female",
        location = AdLocation(latitude = 55.734202, longitude = 37.588063, accuracy = 0.1),
    ),
)
```

##### 插屏广告、激励广告和开屏广告

```kotlin
val adRequest = AdRequest(
    adUnitId = "R-M-XXXXXX-Y",
    targeting = AdTargeting(
        age = "20",
        contextQuery = "context-query",
        contextTags = listOf("context-tag"),
        gender = "female",
        location = AdLocation(latitude = 55.734202, longitude = 37.588063, accuracy = 0.1),
    ),
)
```
