Reputation: 1
Based on this infinite scroll example from google I tried to build an example with multiple slots for Roadblocks. But it seems the reloaded ads are not initialising correctly. In the end it should work like the junkee magazine
My initialising for the Slots:
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();
});
My try to initialise the ads on the reloaded content.
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]);
});
As there is more necessary code here my current code: https://jsbin.com/bebabit/edit?output Click the more button at least 6-8 times and you may have to allow third party scripts (GPT JS) to see the ads.
Thank You!
Upvotes: 0
Views: 353