我在网站上展示了很多广告。目前,有些广告会显示,而其他则不会,但是所有广告脚本的设置方式都相同。以下是标题脚本和示例广告单元脚本。我正在使用映射将某些广告设置为在台式机和其他移动设备上展示,这正针对有问题的广告起作用。
问题本身似乎有所波动,例如,首页显示了x5个MPU和x2页首横幅广告。其中,显示3个MUP和两个排行榜。其余的MPU不执行任何操作。在其他页面上,也有类似的显示响应。如果我删除googletag.pubads()。enableSingleRequest();一些广告打开,而其他正在显示的广告关闭...
我以前没有使用过Dfp,因此不确定最佳配置方法。任何提示将不胜感激。
var googletag = window.googletag || {}; googletag.cmd = googletag.cmd || [];
(function() {
var useSSL = 'https:' == document.location.protocol;
var src = (useSSL ? 'https:' : 'http:') +
'//www.googletagservices.com/tag/js/gpt.js';
document.write('<scr' + 'ipt src="' + src + '"></scr' + 'ipt>');
})();
googletag.cmd.push(function() {
/* Ad unit leaderboard mapping – desktop only */
var mapping1 = googletag.sizeMapping().
addSize([769, 0], [728, 90]). // Laptop/Desktop (creative dsiplayed from 769 upwards)
addSize([320, 0], [[300, 50]]). // mobile show nothing as no 300x50 creative
build();
/* Ad unit leaderboard mapping – tablet and desktop */
var mapping2 = googletag.sizeMapping().
addSize([769, 0], [728, 90]). // Laptop/Desktop show nothing as no 728x90 creative
addSize([320, 0], [[300, 50]]). // Mobile and tablet (creative being displayed from 320 upwards)
build();
/* Create array */
var gptAdSlots = [];
/* OC Header Leaderboard - Global */
gptAdSlots[0] = googletag.defineSlot('/6853333/NEWOCHDR', [[728, 90], [300, 50]], 'div-gpt-ad-1541428303372-0').defineSizeMapping(mapping1).setCollapseEmptyDiv(true).addService(googletag.pubads());
gptAdSlots[1] = googletag.defineSlot('/6853333/NEW_BTN_Button_Ad_Mobile_Global_300x50', [[728, 90], [300, 50]], 'div-gpt-ad-1541438785512-0').defineSizeMapping(mapping2).setCollapseEmptyDiv(true).addService(googletag.pubads());
/* Home - Latest News MPU */
gptAdSlots[2] = googletag.defineSlot('/6853333/NEWOCHPLNMPU', [300, 250], 'div-gpt-ad-1541432416376-0').addService(googletag.pubads());
/* Home - Video MPU */
gptAdSlots[3] = googletag.defineSlot('/6853333/NEWOCHPVIDMPU', [300, 250], 'div-gpt-ad-1541432472828-0').addService(googletag.pubads());
/* Home - lower leaderboard */
gptAdSlots[4] = googletag.defineSlot('/6853333/NEWOCHPLBD', [[728, 90], [300, 50]], 'div-gpt-ad-1541432071852-0').defineSizeMapping(mapping1).setCollapseEmptyDiv(true).addService(googletag.pubads());
// gptAdSlots[5] = googletag.defineSlot('/6853333/NEW_BTN_Button_Ad_Mobile_Global_300x50', [[728, 90], [300, 50]], 'div-gpt-ad-1541438785512-0').defineSizeMapping(mapping2).setCollapseEmptyDiv(true).addService(googletag.pubads());
/* Nav - Insights MPU */
gptAdSlots[6] = googletag.defineSlot('/6853333/NEWOCNIMPU', [300, 250], 'div-gpt-ad-1541433466979-0').addService(googletag.pubads());
/* Ambassador - trending short MPU */
gptAdSlots[7] = googletag.defineSlot('/6853333/NEWOCAMBSMPU', [300, 250], 'div-gpt-ad-1541432354529-0').addService(googletag.pubads());
/* News - Featured articles MPU */
gptAdSlots[8] = googletag.defineSlot('/6853333/NEWOCNEWSFAMPU', [300, 250], 'div-gpt-ad-1541428161405-0').addService(googletag.pubads());
/* News - bottom leaderboard */
gptAdSlots[9] = googletag.defineSlot('/6853333/NEWOCNEWSLBD', [[728, 90], [300, 50]], 'div-gpt-ad-1541428246275-0').defineSizeMapping(mapping1).setCollapseEmptyDiv(true).addService(googletag.pubads());
/* News - detail list MPU */
gptAdSlots[11] = googletag.defineSlot('/6853333/NEWOCNEWSMPU', [300, 250], 'div-gpt-ad-1541428407319-0').addService(googletag.pubads());
/* Videos - leaderboard */
gptAdSlots[12] = googletag.defineSlot('/6853333/NEWOCVIDEOLBD', [[728, 90], [300, 50]], 'div-gpt-ad-1541431980921-0').defineSizeMapping(mapping1).setCollapseEmptyDiv(true).addService(googletag.pubads());
/* Videos - Video detail list MPU */
gptAdSlots[14] = googletag.defineSlot('/6853333/NEWOCVFVMPU', [300, 250], 'div-gpt-ad-1541433185129-0').addService(googletag.pubads());
/* Videos - Featured Videos MPU */
gptAdSlots[15] = googletag.defineSlot('/6853333/NEWOCVDMPU', [300, 250], 'div-gpt-ad-1541433123972-0').addService(googletag.pubads());
/* Events - Trending short MPU */
gptAdSlots[16] = googletag.defineSlot('/6853333/NEWOCETSMPU', [300, 250], 'div-gpt-ad-1541433060761-0').addService(googletag.pubads());
/* Nav - Topics MPU */
gptAdSlots[17] = googletag.defineSlot('/6853333/NEWOCNTMPU', [300, 250], 'div-gpt-ad-1541433523476-0').addService(googletag.pubads());
/* Nav - Multimedia MPU */
gptAdSlots[18] = googletag.defineSlot('/6853333/NEWOCNMMPU', [300, 250], 'div-gpt-ad-1541433657317-0').addService(googletag.pubads());
/* Partners - Trending Short MPU */
gptAdSlots[19] = googletag.defineSlot('/6853333/NEWOCPARTSMPU', [300, 250], 'div-gpt-ad-1541433398379-0').addService(googletag.pubads());
/* Podcasts - Trending Short MPU */
gptAdSlots[20] = googletag.defineSlot('/6853333/NEWOCPODTSMPU', [300, 250], 'div-gpt-ad-1541433238285-0').addService(googletag.pubads());
/* Infographic - Trending Short MPU */
gptAdSlots[21] = googletag.defineSlot('/6853333/NEWOCITSMPU', [300, 250], 'div-gpt-ad-1541433294564-0').addService(googletag.pubads());
/* Journal - Trending Short MPU */
gptAdSlots[22] = googletag.defineSlot('/6853333/NEWOCJTSMPU', [300, 250], 'div-gpt-ad-1541433344917-0').addService(googletag.pubads());
/* Article - related MPU */
gptAdSlots[23] = googletag.defineSlot('/6853333/NEWOCADRAMPU', [300, 250], 'div-gpt-ad-1541432289951-0').addService(googletag.pubads());
/* Article - MPU one */
gptAdSlots[24] = googletag.defineSlot('/6853333/NEWOCADMPU', [300, 250], 'div-gpt-ad-1541432146332-0').addService(googletag.pubads());
/* Article - MPU two */
gptAdSlots[25] = googletag.defineSlot('/6853333/NEWOCADMPU2', [300, 250], 'div-gpt-ad-1541432235724-0').addService(googletag.pubads());
/* Category Landing - one MPU */
gptAdSlots[26] = googletag.defineSlot('/6853333/NEWOCCATTSMPU', [300, 250], 'div-gpt-ad-1541433717945-0').addService(googletag.pubads());
/* Category Landing - two MPU */
gptAdSlots[27] = googletag.defineSlot('/6853333/NEWOCSAMPU1', [300, 250], 'div-gpt-ad-1541433878473-0').addService(googletag.pubads());
/* Start ad fetching */
googletag.pubads().enableSingleRequest();
googletag.enableServices();
});
<div class="advert-container-block">
<div class="mpu">
<div id='div-gpt-ad-1541428407319-0'>
<script>
googletag.cmd.push(function() { googletag.display('div-gpt-ad-1541428407319-0'); });
</script>
</div>
</div>
</div>
答案 0 :(得分:0)
该问题现已解决。供参考,该问题已通过以下解决: