Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Likely alMComplete.
    Whats the code for Google DFP?

    Thread Starter borbs

    (@borbs)

    I want to display ads in every page that is loaded via ajax on an infinite scroll, using Google DFP. I have four different slots in each page. I follow the regular Google DFP code, which is, in my case:

    <script type='text/javascript'>
    var googletag = googletag || {};
    googletag.cmd = googletag.cmd || [];
    (function() {
    var gads = document.createElement('script');
    gads.async = true;
    gads.type = 'text/javascript';
    var useSSL = 'https:' == document.location.protocol;
    gads.src = (useSSL ? 'https:' : 'http:') +
    '//www.googletagservices.com/tag/js/gpt.js';
    var node = document.getElementsByTagName('script')[0];
    node.parentNode.insertBefore(gads, node);
    })();
    </script>
    
    <script type='text/javascript'>
    googletag.cmd.push(function() {
    googletag.defineSlot('/XXXXXXX/ROS_DHTML', [600, 600], 'div-gpt-ad-5').addService(googletag.pubads());
    googletag.defineSlot('/XXXXXXX/ROS_Horizontal', [960, 250], 'div-gpt-ad-6').addService(googletag.pubads());
    googletag.defineSlot('/XXXXXXX/ROS_Interstitial', [1920, 1080], 'div-gpt-ad-7').addService(googletag.pubads());
    googletag.defineSlot('/XXXXXXX/ROS_Txt', [[300, 250], [300, 600]], 'div-gpt-ad-8').addService(googletag.pubads());
    googletag.pubads().collapseEmptyDivs();
    googletag.enableServices();
    });
    </script>

    I then call the ads, again, regularly.

    <div id='div-gpt-ad-8'>
    <script type='text/javascript'>
    googletag.cmd.push(function() { googletag.display('div-gpt-ad-8'); });
    </script>
    </div>

    How can I make the DFP and this callback function to work together? I know about the Advanced Google Publisher Tag, but I’m not the most code savvy in the world, and I just couldn’t adapt it to my needs (specially since I use a lot of slots). So, I thought this would be the easier way…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Previous Post Google DFP’ is closed to new replies.