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

# 广告定位

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

## 设置定位 {#setup}

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

- 针对横幅（[内联](https://ads.yandex.com/helpcenter/zh/dev/unity/adaptive-inline-banner.md) 和 [粘性](https://ads.yandex.com/helpcenter/zh/dev/unity/adaptive-sticky-banner.md)），请使用 `AdRequest` 类。
- 对于 [插屏广告](https://ads.yandex.com/helpcenter/zh/dev/unity/interstitial.md)，[激励广告](https://ads.yandex.com/helpcenter/zh/dev/unity/rewarded.md) 或 [开屏广告](https://ads.yandex.com/helpcenter/zh/dev/unity/app-open-ad.md)，请使用 `AdRequestConfiguration`。

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

#|
|| **参数** | **描述** ||
|| `age` | 用户年龄：字符串格式的数字（例如`"14"`、`"18"`等）。||
|| `gender` | 用户性别：接受 `Gender` 枚举中的值。

请使用 `Gender.MALE` 和 `Gender.FEMALE` 常量获取有效的字符串。||
|| `location` | 由您的应用检测到的用户位置，通过 `Location` 类传递。

设置此参数前，请先获得用户同意，并通过 `MobileAds.SetLocationConsent` 方法将位置使用权限传递给 SDK。||
|| `contextQuery` | 用户在应用中的搜索查询。

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

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


## 定位示例 {#examples}

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

```c#
AdRequest adRequest = new AdRequest.Builder()
	.WithAge("20")
	.WithContextQuery("context-query")
	.WithContextTags(["context-tag"])
	.WithLocation(new Location.Builder().SetLatitude(55.734202).SetLongitude(37.588063).SetHorizontalAccuracy(100).Build())
	.WithGender(Gender.FEMALE)
	.Build();
```

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

```c#
AdRequestConfiguration adRequestConfiguration = new AdRequestConfiguration.Builder("your_block_id")
	.WithAge("20")
	.WithContextQuery("context-query")
	.WithContextTags(["context-tag"])
	.WithLocation(new Location.Builder().SetLatitude(55.734202).SetLongitude(37.588063).SetHorizontalAccuracy(100).Build())
	.WithGender(Gender.FEMALE)
	.Build();
```
