---
metadata:
  - name: generator
    content: Diplodoc Platform v5.66.1
alternate:
  - https://ads.yandex.com/helpcenter/en/monetization/adfox/banner-specs/native-slider.md
  - https://ads.yandex.com/helpcenter/ru/monetization/adfox/banner-specs/native-slider.md
  - https://ads.yandex.com/helpcenter/zh/monetization/adfox/banner-specs/native-slider.md
  - href: https://ads.yandex.com/helpcenter/zh/monetization/adfox/banner-specs/native-slider.md
    type: text/markdown
    title: Markdown version
  - href: https://ads.yandex.com/helpcenter/zh/llms.txt?revision=r22039017
    rel: describedby
---
> **Documentation Index:** Fetch the complete configuration index at https://ads.yandex.com/helpcenter/zh/llms.txt?revision=r22039017

# App Native Slider

{% note warning %}

此广告模板已弃用。请改用 [App Native Carousel ](https://ads.yandex.com/helpcenter/zh/monetization/adfox/banner-specs/app-carousel.md)。

{% endnote %}

**App Native Slider** 是一个由相互关联的广告组成的滑块，并采用原生广告的原理。您可以根据将显示滑块的应用的功能和设计来自定义广告。

App Native Slider 广告示例：

![](../../_images/app-native-slider.gif =450x)

## 图像要求 {#requirements}

- 确保使用高分辨率图像：这将提高横幅在移动设备上的显示质量，这也可能会导致加载时间变长。
- 我们建议使用文件压缩服务（例如 TinyPNG）减小图像文件大小。
- 可接受的图像格式：PNG、GIF（无动画）、JPG。
- 单个文件的最大大小为 300 KB。

## 创建原生横幅 {#customize}

<!-- source: zh/monetization/_includes/adfox-native.md -->
1. 确定要在横幅中包含哪些原生广告元素。
1. 准备 JSON 代码。在代码中指定要自定义的参数（广告元素及其值）。

   {% cut "JSON 示例" %}

   ```json
   {
     "content": [
       "text",
       "button"
     ],
     "text": {
       "value": "Customizable text from an Adfox ad unit"
     },
     "button": {
       "label": "Custom button",
       "link": "https://ya.ru/",
       "backgroundColor": "#5D9B9B"
     }
   }
   ```

   {% endcut %}

   要传递横幅广告 JSON 元素的点击跳转 URL，请使用宏：`%banner.reference_mrc_user1%`。系统将统计横幅广告点击次数，并将用户重定向到 **Transition URL** 参数中指定的广告主网站。

1. 将 JSON 代码写成一行，并使用 `\` 字符转义引号。

   {% cut "带转义引号的 JSON 示例" %}

   ```json
   {   \"content\": [     \"text\",     \"button\"   ],   \"text\": {     \"value\": \"Customizable text from an Adfox ad unit\"   },   \"button\": {     \"label\": \"Custom button\",     \"link\": \"https:\/\/ya.ru\/\",     \"backgroundColor\": \"#5D9B9B\"   }
   ```

   {% endcut %}

1. 为了确保在应用中正确显示原生元素，请在应用端添加对读取 JSON 数据的支持。请注意，JSON 中指定的每个原生广告元素都必须在应用代码中正确实现。

   {% cut "解析 JSON 数据的示例 (Kotlin)" %}

   ```kotlin

   private fun processAdditionalText(rawJson: String) {
       try {
           val jsonObject = JSONObject(rawJson)
           val contentJSONArray = jsonObject.getJSONArray("content")

           repeat(contentJSONArray.length()) { index ->
               val elementName = contentJSONArray.getString(index)
               val elementConfiguration = jsonObject.getJSONObject(elementName)

               when (elementName) {
                   "text" -> addTextToLayout(elementConfiguration, index)
                   "button" -> addButtonToLayout(elementConfiguration, index)
               }
           }
       } catch (e: JSONException) {
           adInfoFragment.log(e.message ?: "JSON parsing error")
       }
   }

   private fun addTextToLayout(textConfiguration: JSONObject, index: Int) {
       val textView = TextView(this).apply {
           setPadding(resources.getDimension(R.dimen.item_padding).toInt())

           text = textConfiguration.getString("value")
       }
       additionalContainer.addView(textView, index)
   }

   private fun addButtonToLayout(buttonConfiguration: JSONObject, index: Int) {
       val buttonView = Button(this).apply {
           setPadding(resources.getDimension(R.dimen.item_padding).toInt())

           text = buttonConfiguration.getString("label")

           val colorHex = buttonConfiguration.getString("backgroundColor")
           setBackgroundColor(Color.parseColor(colorHex))

           setOnClickListener {
               val link = buttonConfiguration.getString("link")
               val intent = Intent(Intent.ACTION_VIEW, Uri.parse(link))
               startActivity(intent)
           }
       }
       additionalContainer.addView(buttonView, index)
   }

   ```
   {% endcut %}

1. 按照[以下说明](#add-banner)添加横幅。

{% cut "原生横幅广告准备阶段"%}

![](../../_images/adfox-additional-json.png)

{% endcut %}
<!-- endsource: zh/monetization/_includes/adfox-native.md -->

## 将横幅添加到 Adfox {#add-banner}

要添加横幅：

1. 在广告系列设置中，转到 **Banners** 选项卡并点击 **Add**。
1. 选择 **App Mobile Native** 横幅类型和 **App Native Slider** 模板。
1. 设置横幅参数：

   {% list tabs %}

   - 主要

      * **Priority**：决定广告系列中横幅显示顺序的数字。数值越高，该横幅相对于同一广告系列中其他横幅的优先级就越高。要了解有关优先级的更多信息，请参见 [Adfox 帮助](https://yandex.com/support2/adfox/en/campaigns/rotation-method)。

      * **Slide N: image**（其中 N 是幻灯片编号）是幻灯片图像。

      * **Slide N: click-through web link**（其中 N 是幻灯片编号）是指向广告主网站的链接。为了确保点击功能正常工作，请确保链接包含协议（`http://` 或 `https://`）。如果用户尚未安装该应用，则会调用此链接，而不是调用指向深层链接的链接。

      * **Slide N: Deeplink**（其中 N 是幻灯片编号）是将用户重定向到 iOS 或 Android 应用中的特定页面的链接。

      * **Slide N: Android BundleID**（其中 N 是幻灯片编号）是 Play 商店中的应用 ID，这是深层链接在 Android 上生效所必须提供的。示例：`ru.yandex.searchplugin`。

      * **Width**：滑块宽度。仅输入以像素为单位的整数，而不指定尺寸。

      * **Height**：滑块高度。仅输入以像素为单位的整数，而不指定尺寸。

      * **Additional text**：如果您需要向广告或广告素材添加自定义元素，请指定[您之前创建的 JSON](#customize)。

         {% cut "已填写的 **Additional text** 的示例" %} 字段

         ![](../../_images/adfox-additional-text.png)

         {% endcut %}

      * **Slide set**：在此字段中，您可以调整幻灯片的数量和类型。向其中添加类似 `%global.InAppSlideN%` 的变量列表（用于不包含深层链接的幻灯片）和类似 `%global.InAppSlideDeeplinkN%` 的变量列表（用于包含深层链接的幻灯片，其中 N 是幻灯片编号）。

          {% cut "填写包含三个带有深层链接幻灯片的滑块字段示例" %}

          ```java
          %global.InAppSlideDeeplink1%
          %global.InAppSlideDeeplink2%
          %global.InAppSlideDeeplink3%
          ```

          {% endcut %}

      * **Start date and time**：必需参数。默认情况下，此日期设置为当前日期。如果您不做更改，横幅将在添加后立即运行（如果其状态设置为 **active**）。

   - 附加

      <!-- source: zh/monetization/_includes/banner-additional.md -->
      * **Name**：输入横幅的名称。如果将此字段留空，则会为其分配一个序列号。

      * **Status**：选择横幅的状态：
         * **active**：横幅已准备好投放。
         * **paused**：横幅展示已暂停。
         * **completed**：横幅将不会被投放。

      * **Disabled on new placements**：此选项默认启用。创建横幅后，它不会自动放置在以下位置：
         * 在您的广告l系列所在的网站或部分中创建的新版位中。
         * 在创建横幅后在广告系列版位设置中启用的版位中。
      如果您禁用此选项，横幅将自动添加到启用了广告系列版位的任意版位中。

      * **Targeting profile**：选择您之前创建的定位配置文件。要了解有关定位配置文件的更多信息，请参见 [Adfox 帮助](https://yandex.com/support2/adfox/en/settings/profiles)。

      * **Events enabled**：此选项用于获取要在第三方系统中跟踪的事件的直接链接。
         要激活该选项，请在 **Placements** 选项卡中点击横幅旁边的 ![](../../_images/code.png)。在打开的窗口中，您将看到事件 1 到 30 的链接。将其复制并发送到第三方系统以进行跟踪。

      * **Impressions total, day, hour**：

         * **Impressions total, day, hour**：横幅展示的最大次数。如果广告系列分布均匀，请设置横幅显示结束日期。一旦展示次数达到最大值，横幅的状态就会更改为 **completed** 并且不再投放。
         * **Impressions per day**：每天的最大展示次数。一旦从当天开始的展示次数达到最大值，展示就会暂停，直到第二天开始。
         * **Impressions per hour**：每小时的最大展示次数。一旦从一小时开始的展示次数达到最大值，展示就会暂停，直到下一小时开始。

      * **Clicks total, per day, per hour**：

         * **Clicks total**：横幅点击的最大次数。如果广告系列分布均匀，请设置横幅显示结束日期。  一旦点击次数达到最大值，横幅的状态将更改为 **Completed** 并且不再投放。
         * **Clicks per day**：每天的最大横幅点击次数。一旦从当天开始的点击次数达到最大值，展示就会暂停，直到第二天开始。
         * **Clicks per hour**：每小时的最大横幅点击次数。一旦从一小时开始的点击次数达到最大值，展示就会暂停，直到下一小时开始。

      * **End time**：要设置结束日期和时间，请首先启用该选项。
      <!-- endsource: zh/monetization/_includes/banner-additional.md -->

   {% endlist %}

1. 要保存横幅，请点击 **Add**。

您可以在横幅事件中设置测量链接：

- **A slider impression tracking pixel** 计算整个滑块的展示次数。
- **An N slide impression tracking pixel**（其中 N 是幻灯片编号），用于计算第 N 张幻灯片的展示次数。
- **The number of clicks for slide N**，其中 N 是幻灯片编号。总体点击统计数据是所有幻灯片的总点击次数。


<!-- source: zh/monetization/_includes/support.md -->
[联系支持部门](https://ads.yandex.com/helpcenter/zh/support/contact.md){.button}


<!-- endsource: zh/monetization/_includes/support.md -->

