我正在尝试在我的测试网站上展示广告,然后再将其用于我的实时网站。
我已将 Admanager 生成的代码放在网页的头部和正文中。广告显示正常,但当我调整屏幕大小时,平板电脑和移动设备上显示相同的广告。我使用 Sizemapping 设置了不同的广告,它在 chrome 检查器中给了我这个错误:
排队的 GPT 命令 TypeError 中的异常:googletag.SizeMapping 不是 Arguments 中的函数。((index):70) at Gk.push (pubads_impl_modern_2019112101.js?21065216:1) at Nk (pubads_impl_modern_2019112101.js?21065216:1) at pubads_impl_modern_2019112101.js?21065216:1 at dq (pubads_impl_modern_2019112101.js?21065216:1)在 pubads_impl_modern_2019112101.js?21065216:1 在 pubads_impl_modern_2019112101.js?21065216:1
我怎样才能解决这个问题?
这是我脑海中的代码:
<script data-ad-client="ca-pub-5630600850555485" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<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('/10643240/test_aanhetbouwen', [[300, 600], [300, 250], [728, 90], [970, 250], [320, 100]], 'div-gpt-ad-4873663-1').addService(googletag.pubads());
googletag.enableServices();
});
</script>
<!-- Start GPT Tag -->
<script async='async' src='https://www.googletagservices.com/tag/js/gpt.js'></script>
<script>
var gptadslots = [];
var googletag = googletag || {cmd:[]};
</script>
<script>
googletag.cmd.push(function() {
var mapping1 = googletag.SizeMapping()
.addSize([1024, 770], [[300, 600]])
.addSize([770, 400], [[300, 250]])
.addSize([1, 1], [[300, 250]])
.build();
//Adslot 1 declaration
gptadslots.push(googletag.defineSlot('/10643240/test_aanhetbouwen', [[300,250],[300,600]], 'div-gpt-ad-4873663-1')
.defineSizeMapping(mapping1)
.addService(googletag.pubads()));
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
</script>
<!-- End GPT Tag -->
这是我在正文中的代码:
<!-- GPT AdSlot 1 for Ad unit 'test_aanhetbouwen' ### Size: [[300,600]] -->
<div id="div-gpt-ad-4873663-1">
<script>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-4873663-1'); });
</script>
</div>
<!-- End AdSlot 1 -->