Google 互动式媒体广告 SDK 常见问题解答
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
- 为什么有的格式无法返回广告?
-
测试广告代码会设置为始终针对有效请求返回广告。这是为了简化集成,并让您更轻松地测试玩家请求和呈现广告的方式。不过,并不是每个地区都会展示
广告格式。如果您的集成正常运行
对测试代码有效,而对您自己的代码无效,原因可能是
以下:
- 您正在向自己的环境中投放格式不受支持的视频。例如,您仅向 iOS 或 Android 设备投放 HTML5 广告。
- 如果您使用的是 Ad Manager,那么您的发布商 ID 目前可能没有任何定位到该 ID 的广告。此外,请确保您已批准相关广告并
Ad Manager 中的广告素材。
- 如果您使用的是 AdSense,则您网站或测试网页的定位条件可能没有任何有效的广告。最常见的原因是
不公开、未抓取的网站。
- 如果您使用的是 Ad Exchange 广告联盟合作伙伴管理功能,并且未设置
descriptionURL
或 descriptionURL
未列在自有或自营网域管理列表中,系统不会向此类网域投放广告。
- 查看 Ad Exchange 视频广告中定义的 minCPM 阈值。每千次展示费用较高可能会导致填充率非常低。要更正此问题,请尝试
从广告请求中移除 minCPM 或移除广告单元参数
(即 slotname),以验证是否会影响填充率。
- 什么样的
descriptionUrl
算是不错的 descriptionUrl
?
-
为了达到最佳效果,
descriptionUrl
所指向网页的内容不应是一系列字词或短语,而应是 1-3 段实际描述相应内容以及您在提供该内容中所扮演的角色。
过去曾成功使用过的方法之一是,从预定义的块中动态拼接 descriptionUrl
网页内容。例如,几句介绍内容的文字、几句介绍您网站所提供内容的文字,以及与每个 AdSense 渠道(例如“娱乐”或“体育”)相关联的几个预定义摘要。如此一来,
内容具有合理且不同的 descriptionUrl
,它们与
它既提供一般信息(如类型描述)
具体信息(与内容直接相关的内容)。
该元数据 HTML 应该非常简单,例如:
<html>
<head>
<title>Domain.com - Your tag line here!</title>
</head>
<body>
<h1>Descriptions</h1>
<h2>About this Content</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. ...</p>
<h2>About Domain.com</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. ...</p>
</body>
</html>
- 为什么我收到“广告响应不含有效的广告类型”错误?
- 出现此错误通常是因为没有任何广告定位到特定
publisherId
(在给定时间段内)。此条件
在一天之中可能会有所变化,而随着广告系列的开始和结束,在几天内可能会有所变化。
您应当检查您希望定位的广告是否已过期,
广告定位条件是否正确。
只要使用测试 publisherId
正确请求、接收和呈现广告,您就可以确保在广告可用时,系统会使用您的正式版 publisherId
正确处理这些广告。
- 您有可供我用于测试的 Ad Manager 视频广告代码吗?
- 示例代码页面提供示例代码。
- 我是否应将
adSlotWidth
和 adSlotHeight
设置为与 Ad Manager 广告代码中的 sz
相同的值?
- 不一定。
adSlotWidth
和 adSlotHeight
必须设置为播放器的宽度/高度,或者您希望广告填充的区域的宽度/高度。AdSense 会根据这些值来确定哪些广告适合投放
进入这个空间Ad Manager 广告代码中的 sz
键值对是一个定位参数,不一定会影响投放的广告素材(详情见下文)。
- 演示广告代码的显示效果良好,但切换为我的广告代码后,就无法显示任何广告了。
-
请进行检查,确保已将内容投放到您所需的广告代码
请求。最简单的查看方法是监控 HTTP 流量。如果 HTML 锚点块中返回了 1x1 像素 grey.gif 图片,则您需要在 Ad Manager 中检查定位条件。
- 我想多次请求使用同一代码的广告,但我的第一个广告
请求。如何解决此问题?
-
如果您多次请求广告,则需要告知广告服务器这些是合法请求,而不是意外重复。SDK
通过两个快速 API 调用来执行此操作:
- 在您的
AdsManager
实例上调用 destroy()
。
这样,当您对
contentComplete()
。您在下次发出请求时会获得新的 AdsManager
。
- 在
AdsLoader
实例上调用 contentComplete()
。这会重置 SDK,以使新广告请求看起来不像是上一个广告请求的副本。
执行上述两个调用后,您可以对 AdsLoader
实例调用 requestAds()
,以获取另一组广告来为您的新视频播放。
- 如何使用 IMA SDK 请求重叠式广告和全幅 AdSense 广告?
-
若要使用 SDK 请求 AdSense 广告,您首先需要获取 AdSense 广告代码。您可以前往 AdSense 视频广告页面详细了解。创建代码后,您需要执行以下操作
发出重叠式广告请求或全幅广告请求的步骤如下:
重叠式广告
- 在
AdsRequest
中,将 ViewModes 设为
NORMAL
。
- 在广告代码中,添加参数
overlay=1
。
全屏广告
- 在
AdsRequest
中,将 ViewModes 设为
FULLSCREEN
。
- 在广告代码中,添加参数
overlay=0
。
- 我点击广告时收到“点击后到达网址无效”错误消息。原因可能是什么?
-
导致此错误的最常见原因是点击跟踪网址未正确转义。如果看到此错误,请进行检查
网址在您的 VAST 响应中进行了正确转义。
- 在 Android 和 iOS SDK 中,有没有办法让整个视频广告都具有可点击性?
- 就整个视频的点击跟踪而言,标准的观看者体验
移动视频的模式出现后,点按视频
暂停播放或显示播放器控件。为了避免用户
而只是想访问
播放器控件 IMA 使用了解详情按钮
用户点击广告并详细了解所宣传的产品。
- 为什么我会看到“VAST 文档为空”出错了?
- 当广告代码返回空的 VAST 文档时,就会发生此错误,表示广告未正常投放。请与您的客户经理或广告服务器代表联系,了解您的广告代码无法正常运行的原因。
- 我可以更改跳过广告框或其他界面元素的大小/文字吗?
- IMA SDK 不支持更改界面元素的布局、大小或内容。
如需详细了解界面元素,请参阅
AdsManager.uiElements
。
- 为什么我在 iOS 设备上无法调节广告的音量?
-
iOS 不允许您以编程方式设置音量。如果您使用的是
HTML5 SDK
adsManager.setVolume()
没有任何影响。因此,iOS SDK 不会在 IMAAdsManager 上提供音量设置器。
- 我可以使用多个线程来初始化和操纵界面吗?
-
界面的所有初始化都必须在主线程上完成。更新后
可以选择实施
后台播放。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThe test ad tags always return ads for valid requests to make integration and testing easier, however, live ads may not always be available for all ad formats, placements or targeting criteria.\u003c/p\u003e\n"],["\u003cp\u003eEnsure your \u003ccode\u003edescriptionUrl\u003c/code\u003e is set to a page on your site with 1-3 paragraphs accurately describing the content for better ad targeting.\u003c/p\u003e\n"],["\u003cp\u003eWhen requesting ads more than once using the same tag, ensure you reset the SDK by calling \u003ccode\u003edestroy()\u003c/code\u003e on \u003ccode\u003eAdsManager\u003c/code\u003e and \u003ccode\u003econtentComplete()\u003c/code\u003e on \u003ccode\u003eAdsLoader\u003c/code\u003e to avoid duplicate requests.\u003c/p\u003e\n"],["\u003cp\u003eThe "Ad response does not contain a valid ad type" error generally indicates that no ads are currently targeted to your publisher ID, time period or ad unit, ensure your ads and creatives are approved, targeted correctly and have not expired.\u003c/p\u003e\n"],["\u003cp\u003eThe IMA SDK does not allow for customization of UI elements like the "Skip Ad" button, and on iOS, programmatic volume control for ads is restricted by the operating system.\u003c/p\u003e\n"]]],[],null,["# Google Interactive Media Ads SDK FAQs\n\n- [Why am I not getting ads back for all formats?](#1)\n- [What does a good descriptionUrl look like?](#2)\n- [Why am I receiving the error \"Ad response does not contain a valid ad type\"?](#3)\n- [Do you have an Ad Manager video ad tag that I can use for testing?](#4)\n- [Should I set the adSlotWidth and adSlotHeight to the same values\n as the sz in my Ad Manager ad tag?](#5)\n- [The demo ad tag looks great, but when I switch it with my ad tag,\n no ad appears.](#7)\n- [I want to request ads using the same tag more than once, but I\n only get ads for my first request. How do I fix this?](#8)\n- [How do I request overlay and full slot AdSense ads using the IMA\n SDK?](#9)\n- [I'm getting an \"Invalid clickthrough URL\" error when I click on my\n ad. What could be the cause?](#10)\n- [In the Android and iOS SDKs, is there a way to make the entire video\n ad clickable?](#11)\n- [Why do I see a \"VAST Document Empty\" error?](#12)\n- [Can I change the size/text of the \"Skip Ad\" box or other UI elements?](#13)\n- [Why can't I change an ad's volume on iOS?](#16)\n- [Can I use multiple threads to initialize and manipulate the UI?](#18)\n\n*** ** * ** ***\n\nWhy am I not getting ads back for all formats?\n:\n The test ad tags are set up to always return ads for valid requests. This is\n meant to facilitate integration and make it easier to test how your player\n requests and renders ads. However, ads are not always available in every\n format for your site, account, or ad unit. If your integration is working\n properly for the test tag but not for your own tag, the cause may be one of\n the following:\n\n - You're serving videos of an unsupported format to your environment. For example, you're serving only HTML5 ads to iOS or Android.\n - If you're using Ad Manager, your publisher ID may not have any ads targeted to it at this time. Also, ensure that you have approved the relevant ads and creatives in Ad Manager.\n - If you're using AdSense, the targeting criteria for your site or test page may not have any active advertisements. The most common cause is the use of private, uncrawled websites.\n - If you're using Ad Exchange Network Partner Management and `descriptionURL` is not set or is not on the owned or operated domains management list, ads do not serve to this.\n - Check the *minCPM* thresholds defined in Ad Exchange Video. A fairly high CPM may result in very low fill rates. To correct this, try either removing the minCPM or removing the ad unit parameter from the ad request (i.e., slotname) to verify whether this is affecting the fill rate.\n\nWhat does a good `descriptionUrl` look like?\n:\n To be most effective, the content of the page that `descriptionUrl`\n points to shouldn't be a collection of words or phrases but rather\n 1-3 paragraphs actually describing the content and your role in providing it.\n One method that has been successful in the past is to stitch together\n `descriptionUrl` page content dynamically from predefined blocks.\n For example, a few sentences about the content, a few sentences about your\n site's offering, and then a few predefined snippets associated with each\n AdSense channel (like \"Entertainment\" or \"Sports\"). As a result, each piece of\n content has a reasonably distinct `descriptionUrl` associated with\n it that provides both general information (such as genre descriptors) as well\n as specific information (content about the content directly).\n\n This metadata HTML should be simple, for example:\n\n ```text\n \u003chtml\u003e\n \u003chead\u003e\n \u003ctitle\u003eDomain.com - Your tag line here!\u003c/title\u003e\n \u003c/head\u003e\n \u003cbody\u003e\n \u003ch1\u003eDescriptions\u003c/h1\u003e\n \u003ch2\u003eAbout this Content\u003c/h2\u003e\n \u003cp\u003eLorem ipsum dolor sit amet, consectetur adipiscing elit. ...\u003c/p\u003e\n \u003ch2\u003eAbout Domain.com\u003c/h2\u003e\n \u003cp\u003eLorem ipsum dolor sit amet, consectetur adipiscing elit. ...\u003c/p\u003e\n \u003c/body\u003e\n \u003c/html\u003e\n \n ```\n\nWhy am I receiving the error \"Ad response does not contain a valid ad type\"?\n: This error generally appears because no ads have been targeted to the\n specific `publisherId` (for the given time period). This condition\n may vary throughout the day, or over several days as campaigns begin and end.\n You should check that the ad you wish to target has not expired and that the\n ad targeting criteria are correct.\n As long as ads are properly requested, received, and rendered using\n the test `publisherId`, you can be sure that these ads are\n properly handled using your live `publisherId` when the ads are\n available.\n\nDo you have an Ad Manager video ad tag that I can use for testing?\n: Sample tags are available on the [sample tags](/interactive-media-ads/docs/sdks/ios/client-side/tags) page.\n\nShould I set the `adSlotWidth` and `adSlotHeight` to the same\nvalues as the `sz` in my Ad Manager ad tag?\n: Not necessarily. The `adSlotWidth` and `adSlotHeight`\n must be set to the width/height of the player or area you want your ads to\n fill. They are used by AdSense to determine which ads are available to fit\n into that space. The `sz` key/value pair in your Ad Manager ad tag is\n a targeting parameter and does not necessarily affect the creative served\n (more information below).\n\nThe demo ad tag looks great, but when I switch it with my ad tag, no ad appears.\n:\n Check to ensure that something is trafficked to the ad tag you are\n requesting. The easiest way to find out is to watch the HTTP traffic. If a\n **1x1 pixel grey.gif** image is returned within an HTML anchor block,\n then you need to check your targeting in Ad Manager.\n\nI want to request ads using the same tag more than once, but I only get ads for my first\nrequest. How do I fix this?\n:\n When you request ads more than once, you need to let the ad server know\n that these are legitimate requests, and not accidental duplicates. The SDK\n does this for you with two quick API calls:\n\n 1. Call `destroy()` on your `AdsManager` instance. This prevents any post-rolls from playing when you make the below call to `contentComplete()`. You get a new `AdsManager` when you make your next request.\n 2. Call `contentComplete()` on your `AdsLoader` instance. This resets the SDK so the new ad request doesn't look like a duplicate of the previous one.\n\n\n After making the two calls above, you can call `requestAds()` on\n your `AdsLoader` instance to get another set of ads to play for your\n new video.\n\nHow do I request overlay and full slot AdSense ads using the IMA SDK?\n\n: To request AdSense ads using the SDK, you need to first obtain an AdSense\n ad tag. You can learn more about that on the [AdSense\n for Video page](//support.google.com/adsense/answer/1705822). Once you have your tag, you need to take the following\n steps to make either an overlay or a full slot ad request:\n\n **Overlay ads**\n\n 1. In your `AdsRequest`, set your ViewModes to `NORMAL`.\n 2. In your ad tag, add the parameter `overlay=1`.\n\n **Full slot ads**\n\n 1. In your `AdsRequest`, set your ViewModes to `FULLSCREEN`.\n 2. In your ad tag, add the parameter `overlay=0`.\n\nI'm getting an \"Invalid clickthrough URL\" error when I click on my ad. What could be the cause?\n:\n The most common cause for this error is an improperly escaped clickthrough\n URL. If you're seeing this error, check to make sure that your clickthrough\n URL is properly escaped in your VAST response.\n\nIn the Android and iOS SDKs, is there a way to make the entire video ad clickable?\n: As far as whole-video click tracking goes, the standard viewer experience\n for mobile video that has emerged is that tapping on a video either\n pauses it or brings up the player controls. To avoid users\n unintentionally clicking on ads when they really just want access to the\n player controls IMA uses the **Learn more** button to let\n users click on an ad and learn more about the product being advertised.\n\nWhy do I see a \"VAST Document Empty\" error?\n: This error occurs when the ad tag returns an empty VAST document, indicating\n that the ad was not served properly. Talk to your account manager\n or ad server representative to see why your ad tag is not working.\n\nCan I change the size/text of the **Skip Ad** box or other UI elements?\n: The IMA SDKs do not support changing the layout, size, or content of UI elements.\n For more details on UI elements, see `AdsManager.uiElements`.\n\nWhy can't I change an ad's volume on iOS?\n:\n iOS does not allow you to set volume programmatically. If you're using the\n HTML5 SDK, `adsManager.setVolume()` has no effect. The iOS SDK does not\n provide a volume setter on the IMAAdsManager for this reason.\n\nCan I use multiple threads to initialize and manipulate the UI?\n:\n\n All initialization of the UI must be done on the main thread. After\n initialization, you can choose to implement\n [Background Ad Playback](/interactive-media-ads/docs/sdks/ios/background_ad_playback)."]]