0

基于这个来自谷歌的无限滚动示例,我尝试构建一个包含多个路障插槽的示例。但似乎重新加载的广告没有正确初始化。最后它应该像瘾君子杂志一样运作

我对插槽的初始化:

googletag.cmd.push(function() {
    adslotSkyLeft = googletag.defineSlot('/5064286/Skyscraper_Left', [120, 600], 'sky-left-ad').
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    adslotSkyRight = googletag.defineSlot('/5064286/Skyscraper_Right', [120, 600], 'sky-right-ad').
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    adslotMrec = googletag.defineSlot('/5064286/SideBar_MREC', [300, 250], 'mrec-ad').
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    adslotLeader = googletag.defineSlot('/5064286/Leaderboards', [[970, 250], [970, 90], [728, 90]], 'leaderboard-ad').
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    googletag.pubads().enableSingleRequest();
    googletag.pubads().disableInitialLoad();
    googletag.enableServices();
});

我尝试在重新加载的内容上初始化广告。

googletag.cmd.push(function() {
    var adslotSkyLeftReload = googletag.defineSlot('/5064286/Skyscraper_Left', [120, 600], 'sky-left-ad-' + newId).
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    var adslotSkyRightReload = googletag.defineSlot('/5064286/Skyscraper_Right', [120, 600], 'sky-right-ad-' + newId).
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    var adslotMrecReload = googletag.defineSlot('/5064286/SideBar_MREC', [300, 250], 'mrec-ad-' + newId).
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    var adslotLeaderReload = googletag.defineSlot('/5064286/Leaderboards', [[970, 250], [970, 90], [728, 90]], 'leaderboard-ad-' + newId).
    setTargeting("test","infinitescroll").
    addService(googletag.pubads());

    googletag.pubads().enableSingleRequest();

    googletag.display('sky-left-ad-' + newId);
    googletag.display('sky-right-ad-' + newId);
    googletag.display('mrec-ad-' + newId);
    googletag.display('leaderboard-ad-' + newId);

    googletag.pubads().refresh([adslotSkyLeftReload, adslotSkyRightReload, adslotMrecReload, adslotLeaderReload]);
});

由于这里有更多必要的代码,我当前的代码:https ://jsbin.com/bebabit/edit?output单击更多按钮至少 6-8 次,您可能必须允许第三方脚本(GPT JS)才能看到广告。

谢谢你!

4

0 回答 0