Reusing DFP slots within infinite scroll

Infinite scroll on the index view and article view seems to be all the rage these days. TIME reports their bounce rate went down by 15 percentage points with their redesign. At some point in the discussion, AdOps will raise their hand and say “how can we get ads in the scroll experience?”

Short answer: with code! Because AdOps only wants to create a limited set of ad slots, and Google DFP slots can be used once per page, you’ll need to display the slot first, and reload it for each subsequent use.

The slots are added dynamically as the user scrolls. If a given slot has already been loaded once, then the next time we try to use it we actually pull the first instance over to our new slot, reload it, and add a placeholder for its old position so the page height doesn’t jump. We can use the same trick scrolling back up, simply replacing the placeholder with the refreshed ad.

Google’s documentation has a similar example that’s a good reference point for methods, etc. Pay attention to googletag.refresh( unit ); and googletag.pubads().refresh([unitInstance]);unitInstance is what’s returned by googletag.defineSlot(), so you’ll need to store that somewhere for later reference.

I look forward to hearing about the straightforward approach I missed…