โหลดโฆษณาล่วงหน้า
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
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 Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[[["\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."]]