Google 發布商廣告代碼範例
本節包含 Google 發布商廣告代碼 (GPT) 程式庫的一系列範例和相關資源。
您也可以在 GitHub 存放區中找到本節的大部分內容。依據 Apache 授權 2.0 規定,程式碼範例及相關說明文件是以開放原始碼的形式發布。
嘗試使用 GPT 範例製作工具 (Beta 版) 建構您自己的自訂範例!
顯示受限制的廣告
在沒有取得 Cookie 或其他本機 ID 使用同意聲明的情況下顯示廣告。
Ad sizes
Specify which ad sizes are eligible to serve to an ad slot.
Control SRA batching
Precisely control which ad slots are requested when in Single Request Architecture (SRA) mode.
Key-value targeting
Use key-value targeting to control the ads eligible to serve to specific ad slots.
[null,null,[],[[["This section offers a variety of Google Publisher Tag (GPT) examples and resources, with much of the content mirrored in a dedicated GitHub repository."],["The code and documentation are open-source and available under the Apache License 2.0."],["Users can explore and create custom GPT samples using the GPT sample builder (beta)."]]],["The provided content details resources for the Google Publisher Tag (GPT) library, offering examples and sample code. This code, along with documentation, is available open-source under the Apache License 2.0 in a GitHub repository. Users can also build custom samples using the GPT sample builder (beta). Resources cover diverse topics, including JavaScript, TypeScript, events, multiple ads, performance, privacy, targeting, shadow DOM, and web components.\n"]]