If you have a fairly straightforward setup, then let’s take a look at Google’s documentation first. It has a sample code that uses a button at the end of the article to dynamically generate new content. You can use the same template with slight changes to implement ads on your infinite pages.
Need some context into what’s happening?
- You are declaring and defining the ad slot “googletag.defineSlot(‘/6355419/Travel’, [728, 90], ‘leaderboard’)” that’ll be on the page in the header.
- Then, you are enabling SRA (if you need competitive exclusions and roadblocks) and services.
- When the page loads, you are using “googletag.display(slot);” to call the slot and fetch an ad. You can repeat this process as the user scrolls down the page to render ads.
As GAM (Google DFP) slots can be used once per page, you have to reload it as the new page gets loaded. In other words, display the slot first and reload it again and again to show ads on the new pages.
The slots are added dynamically as the users scrolls the page. You can define the position (say, add a slot after every 3rd paragraph) or let your monetization partner do it for you. For instance, at Automatad, we can enable ‘dynamic loading ads’ on infinite pages via our platform with a few clicks.