Google 互動式媒體廣告 SDK 常見問題
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
- 為什麼我無法取回所有格式的廣告?
-
測試廣告代碼的設定是一律針對有效請求傳回廣告。這是
不但有利於整合,也能方便您測試播放器
請求及顯示廣告不過,並非每一種
網站、帳戶或廣告單元的格式。如果整合項目運作正常
測試代碼能正常運作,但不適用於您自己的代碼,原因可能是以下
包括:
- 您放送的影片格式不受支援。例如:
您只在 iOS 或 Android 上放送 HTML5 廣告。
- 如果您使用的是 Ad Manager,您的發布商 ID 可能目前沒有任何廣告指定至
並確認已核准相關廣告和
廣告素材。
- 如果您使用的是 AdSense,您網站或測試頁的指定條件可能會
沒有任何有效的廣告。最常見的原因是
私人且未檢索的網站。
- 如果您使用 Ad Exchange「聯播網夥伴管理」功能
descriptionURL
未設定或不在自有自營上
網域管理清單上的廣告,廣告就不會在這個網址放送。
- 查看 Ad Exchange 影片廣告中定義的「最低千次曝光出價」門檻。minCPMA 罩杯
千次曝光出價非常高,廣告供應率可能就會非常低。若要修正此問題,請嘗試
請從廣告請求中移除最低千次曝光出價,或移除廣告單元參數
(例如 Slotname),確認廣告是否會影響供應率。
- 怎樣的
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
正確處理
廣告。
- Google 是否提供測試用的 Ad Manager 影片廣告代碼?
- 請前往「範例代碼」頁面取得範例代碼。
- 我應該將
adSlotWidth
和 adSlotHeight
設為相同的值
做為 Ad Manager 廣告代碼中的 sz
嗎?
- 不一定。《
adSlotWidth
》和《adSlotHeight
》
必須設為廣告目標播放器或區域的寬度/高度
填滿。AdSense 會使用這些參數判斷哪些廣告有空
在這個空間中Ad Manager 廣告代碼中的 sz
鍵/值組合為
指定目標參數,不一定會影響放送的廣告素材
(詳情請見下文)。
- 示範的廣告代碼看起來很棒,但是當我切換成我的廣告代碼時,卻沒有出現廣告。
-
檢查以確定有廣告投放至您的廣告代碼
資源。最簡單的方法就是觀察 HTTP 流量。如果
HTML 錨定區塊中傳回 1x1 pixel grey.gif 圖片,
您必須在 Ad Manager 中檢查指定目標
- 我想多次使用相同代碼來請求廣告,但只產生第一個廣告
請求。該如何解決這個問題?
-
多次請求廣告時,請務必讓廣告伺服器知道
這些是合法要求,並非意外重複。SDK
就可以透過兩項快速 API 呼叫來達成這個目的:
- 在
AdsManager
執行個體上呼叫 destroy()
。
這樣當您以下列呼叫
contentComplete()
。您可獲得新的 AdsManager
有助於您提出下一個要求
- 透過
AdsLoader
呼叫 contentComplete()
執行個體。這會重設 SDK,因此新的廣告請求看起來像
重複項目的副本
,瞭解如何調查及移除這項存取權。
完成上述兩個呼叫後,您可以在下列位置呼叫 requestAds()
:
您的 AdsLoader
例項,以便替您的
新增影片
- 如何使用 IMA SDK 請求重疊廣告和全版位 AdSense 廣告?
-
如要使用 SDK 請求 AdSense 廣告,您必須先取得 AdSense
廣告代碼。詳細資訊請見 AdSense
。取得代碼後,您必須執行以下操作
提出重疊或完整版位廣告請求的步驟:
重疊廣告
- 在
AdsRequest
中,將 ViewModes 設為
NORMAL
。
- 在廣告代碼中,新增參數
overlay=1
。
,瞭解如何調查及移除這項存取權。
全版位廣告
- 在
AdsRequest
中,將 ViewModes 設為
FULLSCREEN
。
- 在廣告代碼中,新增參數
overlay=0
。
- 我看到「無效的到達網址」發生錯誤請問可能原因為何?
-
發生此錯誤的最常見原因為 4 錯誤逸出的點閱
網址。如果您看到這個錯誤,請檢查以確認點閱率
VAST 回應中的網址正確逸出。
- 為什麼我會看到「VAST 文件空白」錯誤訊息?
- 如果廣告代碼傳回空白的 VAST 文件,就會發生這個錯誤。
廣告無法正常放送請洽詢客戶經理
或廣告伺服器代表,瞭解廣告代碼無法運作的原因。
- 我可以變更「略過廣告」方塊或其他 UI 元素的大小/文字嗎?
- IMA SDK 不支援變更 UI 元素的版面配置、大小或內容。
如要進一步瞭解 UI 元素,請參閱
AdsManager.uiElements
。
- HTML5 SDK 支援原生影片控制項嗎?
-
不行,HTML5 SDK 不支援原生控制項。
- 畫面顯示「無法執行『播放』」在「HTMLMediaElement」中:API 只能啟動
「透過使用者手勢」我的 HTML5 導入作業該如何解決這個問題?
-
使用行動裝置時,你必須呼叫
adDisplayContainer.initialize()
計算使用者動作 (例如輕觸) 時產生的結果。如果您是
您很可能會在非使用者啟動的環境中呼叫這個錯誤。請注意
必須是使用者動作的「直接」結果。舉例來說,假設您回覆了
「輕觸」呼叫事件,然後使用影片播放器的「播放」要通話的活動
initialize()
,SDK 會傳回這個錯誤。您必須以下列身分呼叫 initialize()
:
輕觸事件本身的結果
- 如何將鍵盤焦點移至廣告點擊?
-
如果您使用鍵盤控制項管理播放器,可能會發現這些設定無法正常運作
adDisplayContainer
的點擊次數。這是因為使用者按下廣告後
鍵盤焦點會切換為 IMA iframe。為了讓鍵盤焦點聚焦在內容播放器,請
利用
CLICK
事件,將鍵盤焦點移回所需容器。請參閱下列程式碼片段:
詳細資料:
adsManager.addEventListener(
google.ima.AdEvent.Type.CLICK,
function(){
window.focus();
// Or another method to return focus to the desired container.
});
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\u003cp\u003eThe IMA HTML5 SDK facilitates ad integration and testing, but live ads depend on factors like ad targeting, formats, and publisher settings.\u003c/p\u003e\n"],["\u003cp\u003eIf your ad tag isn't working, review your Ad Manager targeting, ensure your descriptionUrl is properly set up, and check for any errors in your VAST response.\u003c/p\u003e\n"],["\u003cp\u003eFor repeated ad requests, use \u003ccode\u003edestroy()\u003c/code\u003e on the AdsManager and \u003ccode\u003econtentComplete()\u003c/code\u003e on the AdsLoader to avoid duplicate requests.\u003c/p\u003e\n"],["\u003cp\u003eNative video controls are not supported with the HTML5 SDK, and on mobile devices, \u003ccode\u003eadDisplayContainer.initialize()\u003c/code\u003e must be called directly as a result of a user action.\u003c/p\u003e\n"],["\u003cp\u003eKeyboard focus can be managed by utilizing the CLICK event and transferring it back to the content player.\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- [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- [Are native video controls supported with the HTML5 SDK?](#15)\n- [I'm seeing \"Failed to execute 'play' on 'HTMLMediaElement': API can only be\n initiated by a user gesture\" in my HTML5 implementation. How do I fix this?](#17)\n- [How do I handle keyboard focus on ad clicks?](#19)\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/html5/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\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\nAre native video controls supported with the HTML5 SDK?\n:\n No, the HTML5 SDK does not support native controls.\n\nI'm seeing \"Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated\nby a user gesture\" in my HTML5 implementation. How do I fix this?\n:\n On mobile devices, you must call `adDisplayContainer.initialize()`\n as the result of a user action (such as a tap). If you're\n seeing this error, you're most likely calling it on a non-user-initiated context. Note that it\n must be the **direct** result of a user action. For example, if you respond to a\n \"tap\" event by playing a video, and then use the video player's \"play\" event to call\n `initialize()`, the SDK returns this error. You must call `initialize()` as\n the result of the tap event itself.\n\nHow do I handle keyboard focus on ad clicks?\n:\n If you use keyboard controls for your player you may notice that they will no longer work\n following clicks on the `adDisplayContainer`. This is because, once an ad is clicked\n keyboard focus is switched to the IMA iframe. To keep keyboard focus on the content player, please\n utilize the\n [CLICK](/interactive-media-ads/docs/sdks/html5/client-side/reference/js/google.ima.AdEvent)\n event to transfer keyboard focus back to the desired container. See the following code snippet for\n more details: \n\n ```text\n adsManager.addEventListener(\n google.ima.AdEvent.Type.CLICK,\n function(){\n window.focus();\n // Or another method to return focus to the desired container.\n });\n \n ```"]]