预加载广告
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Ad Placement API 可下载并缓存广告,以在 adBreak()
调用中使用。默认情况下,它使用一组自动启发法来确定下载广告的最佳时机。但是,这些启发法可能意味着,广告没有在您游戏中的第一个展示位置之前加载(例如,您在游戏加载时才首次调用 adBreak()
)。
您可以使用 adConfig()
调用调整此行为,以强制立即预加载广告,如下所示。
<script async
src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-123456789"
crossorigin="anonymous">
</script>
<script>
window.adsbygoogle = window.adsbygoogle || [];
var adBreak = adConfig = function(o) {adsbygoogle.push(o);}
adConfig({preloadAdBreaks: 'on'});
</script>
重要提示:如果您想强制预加载广告,则应在第一次调用 adBreak()
之前执行此调用。为 preloadAdBreaks
设置值后,任何尝试更改此值的后续操作都会被忽略。
要确保在游戏早期展示广告,您可以执行以下操作:
- 通过调用
adConfig({preloadAdBreaks: 'on'})
确保广告已预加载。这可确保在第一次调用 adBreak()
之前有可以投放的广告。
- 缩短
data-ad-frequency-hint
,提高广告展示频次。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThe Ads Placement API downloads and caches ads for use within your game, utilizing heuristics to optimize download timing.\u003c/p\u003e\n"],["\u003cp\u003eYou can force immediate ad preloading by calling \u003ccode\u003eadConfig({preloadAdBreaks: 'on'})\u003c/code\u003e before your first \u003ccode\u003eadBreak()\u003c/code\u003e call.\u003c/p\u003e\n"],["\u003cp\u003eTo ensure early ad display, preload ads and adjust \u003ccode\u003edata-ad-frequency-hint\u003c/code\u003e for increased frequency.\u003c/p\u003e\n"]]],["The Ads Placement API manages ad downloads and caching for `adBreak()` calls. To ensure ads are ready for the initial placement, use `adConfig({preloadAdBreaks: 'on'})` to force immediate preloading before the first `adBreak()` call. This overrides the default automatic heuristics. Setting `preloadAdBreaks` can only happen once, as subsequent changes are ignored. Another method for early ads is to reduce `data-ad-frequency-hint` so ads are shown more often.\n"],null,["# Preload ads\n\nThe Ads Placement API downloads and caches ads for use in `adBreak()` calls.\nBy default it uses a set of automatic heuristics to determine the best times to\ndownload ads. However, these heuristics may mean that an ad has not yet been\nloaded before the very first placement in your game (such as your first call to\n`adBreak()` just as your game is loading).\n\nYou can adjust this behaviour using the `adConfig()` call to force preloading of\nads immediately as follows. \n\n \u003cscript async\n src=\"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=\u003cvar translate=\"no\"\u003eca-pub-123456789\u003c/var\u003e\"\n crossorigin=\"anonymous\"\u003e\n \u003c/script\u003e\n \u003cscript\u003e\n window.adsbygoogle = window.adsbygoogle || [];\n var adBreak = adConfig = function(o) {adsbygoogle.push(o);}\n adConfig({preloadAdBreaks: 'on'});\n \u003c/script\u003e\n\n**Important** : If you want to force preloading of ads, you\nshould make this call before the first call to `adBreak()`. Once\nyou've set a value for `preloadAdBreaks`, any subsequent attempts to\nchange it are ignored.\n\nTo help ensure that ads show early in you game, you can:\n\n1. Make sure that ads are preloaded by calling `adConfig({preloadAdBreaks: 'on'})`. This ensures that there is an ad ready to go before the first call to `adBreak()`.\n2. Reduce the `data-ad-frequency-hint` so that ads show more frequently."]]