Tải trước quảng cáo
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
API Vị trí đặt quảng cáo tải xuống và lưu vào bộ nhớ đệm quảng cáo để sử dụng trong các lệnh gọi adBreak()
.
Theo mặc định, hệ thống sẽ sử dụng một bộ phương pháp phỏng đoán tự động để xác định thời điểm tốt nhất để tải quảng cáo xuống. Tuy nhiên, các phương pháp phỏng đoán này có thể có nghĩa là quảng cáo chưa được tải trước vị trí đầu tiên trong trò chơi của bạn (chẳng hạn như lệnh gọi đầu tiên đến adBreak()
ngay khi trò chơi của bạn đang tải).
Bạn có thể điều chỉnh hành vi này bằng cách sử dụng lệnh gọi adConfig()
để buộc tải trước quảng cáo ngay lập tức như sau.
<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>
Quan trọng: Nếu muốn buộc tải trước quảng cáo, bạn nên thực hiện lệnh gọi này trước lệnh gọi đầu tiên đến adBreak()
. Sau khi bạn đặt một giá trị cho preloadAdBreaks
, mọi nỗ lực thay đổi giá trị này sau đó đều sẽ bị bỏ qua.
Để đảm bảo quảng cáo xuất hiện sớm trong trò chơi, bạn có thể:
- Đảm bảo rằng quảng cáo được tải trước bằng cách gọi
adConfig({preloadAdBreaks: 'on'})
. Điều này đảm bảo rằng có một quảng cáo sẵn sàng hiển thị trước lệnh gọi đầu tiên đến adBreak()
.
- Giảm
data-ad-frequency-hint
để quảng cáo xuất hiện thường xuyên hơn.
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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."]]