我是谷歌广告管理器( DFP )的新手,需要一些帮助来设置我的DFP库存并在页面上实现它。考虑到我的网站是一个小的新闻网站,我的网站有5个部分-世界/商业/政治/娱乐/体育。每个部分至少有3-5个广告位置,包括一些大小相同的位置,即体育部分有两个300x250的位置,而政治部分有三个728x90的位置。
我采取的方法是在DFP中创建五个广告位,如下所示-
/12345678/website.com/world /12345678/website.com/sports /12345678/website.com/business /12345678/website.com/entertainment /12345678/website.com/politics
现在我在这里面临的更大的挑战是,我是否应该调用
googletag
.defineSlot('/12345678/website.com/sports',
[[300, 250], [728, 90], [300, 250]], 'div-gpt-sports12345')
.addService(googletag.pubads());我的页面主体是否会被编码为-
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
window.googletag = window.googletag || {cmd: []};
googletag.cmd.push(function() {
googletag.defineSlot('/21871128741/teststack', [[300, 250]], 'div-mrec1').addService(googletag.pubads());
googletag.defineSlot('/21871128741/teststack', [[300, 250]], 'div-mrec2').addService(googletag.pubads());
googletag.defineSlot('/21871128741/teststack', [[728, 90]], 'div-lb728x90_1').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
<!-- /21871128741/teststack/300x250 -->
<div id='div-mrec1' style='width: 300px; height: 250px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-mrec1'); });
</script>
</div>
<!-- /21871128741/teststack/300x250 -->
<div id='div-mrec2' style='width: 300px; height: 250px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-mrec2'); });
</script>
</div>
<!-- /21871128741/teststack/300x250 -->
<div id='div-lb728x90_1' style='width: 728px; height: 90px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-lb728x90_1'); });
</script>
</div>
我还尝试了另一个版本,使用其独特的子广告单元调用gpt广告位。
<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
window.googletag = window.googletag || {cmd: []};
googletag.cmd.push(function() {
googletag.defineSlot('/21871128741/teststack/mrec1', [[300, 250]], 'div-mrec1').addService(googletag.pubads());
googletag.defineSlot('/21871128741/teststack/mrec2', [[300, 250]], 'div-mrec2').addService(googletag.pubads());
googletag.defineSlot('/21871128741/teststack/lb728x90_1', [[728, 90]], 'div-lb728x90_1').addService(googletag.pubads());
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
<!-- /21871128741/teststack/300x250 -->
<div id='div-mrec1' style='width: 300px; height: 250px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-mrec1'); });
</script>
</div>
<!-- /21871128741/teststack/300x250 -->
<div id='div-mrec2' style='width: 300px; height: 250px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-mrec2'); });
</script>
</div>
<!-- /21871128741/teststack/300x250 -->
<div id='div-lb728x90_1' style='width: 728px; height: 90px;'>
<script>
googletag.cmd.push(function() { googletag.display('div-lb728x90_1'); });
</script>
</div>
发布于 2021-04-21 21:28:24
考虑到您的需求,您必须为同一页面定义多个插槽:
每个定义的插槽都链接到一个div ID (作为详细的here):
googletag.Slot googletag.defineSlot(adUnitPath, size, opt_div) 其中:
在您的代码示例中,您尝试在同一DOM中使用相同的div ID 3次,并且只声明了一个adslot...你应该做的更像是:
//banner definition
googletag.defineSlot('/12345678/website.com/sports',[[728, 90]], 'div-banner').addService(googletag.pubads());
//mpu1 definition
googletag.defineSlot('/12345678/website.com/sports',[[300, 250]], 'div-mpu1').addService(googletag.pubads());
//mpu2 definition
googletag.defineSlot('/12345678/website.com/sports',[[300, 250]], 'div-mpu2').addService(googletag.pubads());在这种情况下,adserver将生成3个adcall(每个定义和显示的位置一个)。
为确保您能够包括或排除页面上的某个mpus,您可以添加以下键值:
横幅= 728,90
为此,您必须在每个mpu插槽上执行setTargetings (有关详细信息,请使用here):
//mpu1 definition
googletag.defineSlot('/12345678/website.com/sports',[[300, 250]], 'div-mpu1').setTargeting('position', '1').addService(googletag.pubads());
//mpu2 definition
googletag.defineSlot('/12345678/website.com/sports',[[300, 250]], 'div-mpu2').setTargeting('position', '2').addService(googletag.pubads());https://stackoverflow.com/questions/67171767
复制相似问题