Ad Manager Using Google DFP

Discussion in 'General Support and Questions' started by Mouth, Feb 20, 2012.

  1. Mouth New Member

    Anyone using Google DFP, and trying to implement?

    The DFP ad insertion code uses separate <head> and <body> sections, and looks to be failing when I place the DFP code from both into the Source Code for a custom code banner.

    Anyone using DFP and has successfully implemented it?
  2. Robbo Staff Member

    Maybe it needs to be in an iframe?
  3. Mouth New Member

    Urgghh, iframe is such a disgusting word :)

    I found that editing teh templates for the style and placing the header section into page_container_js_head is the way to go. Then the body section into Ad Manager.

    Thanks
  4. Robbo Staff Member

    Yes indeed it is :) You could have also created a custom position for the head area and used two ads to show it. However, I think this could be a common issue with other ad providers. I need to add a section for head JS in the edit ad area so you can do this on a per ad basis.
  5. Mouth New Member

    But also a global head JS too. Google DFP, for example, only adds a single extra line per ad location and it would be inefficient to have to replicate the entire head JS to each ad to ensure it was active.
  6. Robbo Staff Member

    So to have multiple ads you would only need the head stuff in once?

    Down the line I want to create new ad types for the main ad providers. So you would go "Create Google DFP" and then put in just the unique part of it. Even further down the line I would like to integrate deeply with ad providers so you can sign up, create and display ads from within your ACP.
    Mouth likes this.
  7. Mouth New Member

    Correct.

    Here, as an example, is the head JS from Google DFP ...


    HTML:
    <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('/2799641/Sidebar', [142, 180], 'div-gpt-ad-1329816300296-0').addService(googletag.pubads());
    googletag.defineSlot('/2799641/Text', [234, 60], 'div-gpt-ad-1329816300296-1').addService(googletag.pubads());
    googletag.defineSlot('/2799641/TopBanner', [728, 90], 'div-gpt-ad-1329816300296-2').addService(googletag.pubads());
    googletag.pubads().enableSingleRequest();
    googletag.enableServices();
    });
    </script>
    The three lines near the bottom, beginning "googletag.defineSlot("... are the unique part, and you could have between 1 and xx lines here depending upon how much inventory/positions you have defined within DFP.

    Google DFP has 3 delivery code types/methods - syncronous, asyncronous, and ad manager (old type). Each type/method has different head JS, but for the purposes of your Ad Manager and xenForo you'd probably only want to support one method, with asynchronous being the better/fastest
    Robbo likes this.

Share This Page