(written by Olive Net)
I’ve been setting up responsive DFP ads that reload on a screen resize event. This uses the command
googletag.pubads().refresh();
It struck me that this might also be used after a scroll event to effectively have more than the regulation 3 adslots on a long page (assuming all DFP adslots are Adsense enabled and following Adsense rules).
After the top of the page has been scrolled away from, there is no need to reload the hidden ad units, they would be set to
display: none;
Another set of 3 ads further down the page loaded set to display: block, and the refresh called instead.
In fact it ought to be possible to only load any ads within the view window and reload on completion of a scroll action.
Has anyone come across anything like this? I can’t find anything on Google, although this is getting warm: Google Groups
https://gist.github.com/RubaXa/5569075 from Lebedev Konstantin is a mod that gives an event on the end of a user scroll. Otherwise jQuery scroll fires constantly.
(Resource no longer exists) / (Resource no longer exists) jQuery visible gives a true/false depending on whether an element is in the view window or not.
Add to header: the div-ad-######## is from the DFP adslot code.
That will give an alert when the ad scrolls in to view, but could be used to carry out a calculation of what ads are visible and adjust the dfp code accordingly, before carrying out a refresh.
I'll crack on with this when I next have time. If anyone else wants to try in the mean time, please do! It seems like a good idea but I'm strapped for time.
After a lot of trial and error with different jQuery plugins (one example in the post above, since scrapped), I settled on Waypoints, and the solution is pretty much given here. You'll see that as an ad comes in to view an action is taken:
Scroll Analytics with jQuery Waypoints
the only significant difference is that the action is to use jQuery append to move the DFP adslot code, then DFP refresh to reload the ad. This is my centre column function, that deals with moving the Leaderboard I described above. Note, that the refresh method takes an adslot object, not the name of the adslot.
I still have pretty scrappy code, with hardcoded ids and so on, so I can't give a complete solution, but if anyone wants more information just ask.
The do refer to it as a limit per 'page,' not a limit on a screen - https://support.google.com/adsense/answer/1346295#Google_ad_limit_per_page
I think you are playing with fire with this one unless the adsense account is not all that important to you,
Chris