javascript - Google Ad Manager (DFP) 投放空白/空广告素材
问题描述
我想要一个提供 5 个横幅并在它们之间旋转的订单项。到目前为止,一切都很好。这很容易。
现在我不想惹恼用户并且想要某种广告暂停。就像每 5 次中的 1 次一样,不显示广告。
我尝试创建空广告素材并调用collapseEmptyDivs(true)
,但无法创建空广告素材。有没有人知道如何在 DFP 中创建空白/空广告素材
解决方案
according to the GPT documentation (here) about collapsEmptyDivs(true) :
Enables collapsing of slot divs so that they don't take up any space on the page when there is no ad content to display.
This means the ad slots will collapse only if there is no ad to display. Therefore, no need to create an empty ad on Google Ad Manager Interface. To make it work properly, collapseEmptyDivs will need to be declared on your page when you define the GPT tag options (in head scripts). Here is a sample :
<script async='async' src='https://www.googletagservices.com/tag/js/gpt.js'></script>
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];
</script>
<script>
googletag.cmd.push(function() {
// Start: GPT Adslot Definition
googletag.defineSlot('gamNetworkId/siteName/sitePage', [[300,250], [300,600]], 'pave').addService(googletag.pubads());
//generic options
googletag.pubads().enableSingleRequest();
googletag.pubads().setCentering(true);
googletag.pubads().collapseEmptyDivs(true);
googletag.enableServices();
});
</script>
On Google Ad Manager interface : you just have to apply a capping on your current line item to make sure the users will not see "too much" ads.
推荐阅读
- dart - 如何转换 FutureBuilder
到 BoxDecoraiton Image - rest - REST API:基于角色设计路由
- google-apps-script - 网页上显示的 Google Script 短标签
- java - 如何使用双缓冲消除闪烁(java swing)
- java - 介质尺寸的 Java 打印问题
- android - 是否可以将 Unity 游戏嵌入到 Flutter 应用程序中?
- performance - Fortran 中的高效(快速)二叉树
- android - 当我按下 textview 时应用程序崩溃
- c++ - 调用 SetWindowLongPtr 时出现未处理的异常
- python - 如何使用将服务器链接到在暴露的本地主机上运行的烧瓶应用程序