Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Changed DFP to GAM


The A9 Server-to-Server (S2S) wrapper solution and client-side code is not a component of any other wrapper (e.g., Prebid). This requires running the code in parallel with OpenWrap. OpenWrap manages the entire process of detecting slots and attaching bids to DFP GAM and does not expose any functionality to request a bid that can be consumed. Therefore, the code cannot run in parallel using callbacks and custom handling.  


Handling Pre-Timeout Call to


GAM in Case of External Partners

When we introduce partners outside of OpenWrap, any notification and synchronization between OpenWrap and external bidders are not available. This means the only point of synchronization is the OpenWrap timeout event when a call to DFP GAM is fired.

To handle this situation, there should be tight coupling between external bidders for notification for each slot when a bid is available. Unfortunately, building this tight integration is complicated and require many events definitions on A9/Publisher end as well as ingestion of APIs in OpenWrap.


  1. registerExternalBidders() – This function will notify OpenWrap that there are one or more eternal bidders present for wrapper needs to wait before calling DFPGAM.
    The call to this function should happen as soon as OpenWrap script loads.
  2. notifyExternalBiddingComplete() – Will notify OpenWrap that all external bidders have completed execution, once per page. This function should be called as soon as bids from all external bidders (A9+ any bidders applicable) is available.


Sample Code with the Implementation. You can check the live working example here.

titleDFP is now called, Google Ad Manager (GAM)…

When you see DFP mentioned in this guide, remember that it is referring to GAM.

Code Block
<html lang="en-us">
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>Wrapper Tag GPT Async Demo with A9</title>
    <h4>GPT implementation is ASYNC SRA <a href="">(Refer this for types of GPT Tags)</a></h4>
    <!-- OpwenWrap Script begins here -->
    <script type="text/javascript">
    var PWT={}; //Initialize Namespace
    var notifyId;
    var googletag = googletag || {};
    googletag.cmd = googletag.cmd || [];
    PWT.jsLoaded = function(){ //PubMatic pwt.js on load callback is used to load GPT
        (function() {
            var gads = document.createElement('script');
            var useSSL = 'https:' == document.location.protocol;
            gads.src = (useSSL ? 'https:' : 'http:') + '//';
            var node = document.getElementsByTagName('script')[0];
            node.parentNode.insertBefore(gads, node);
    (function() {
        var purl = window.location.href;
        var url = '//';
        var profileVersionId = '';
            var regexp = /pwtv=(.*?)(&|$)/g;
            var matches = regexp.exec(purl);
            if(matches.length >= 2 && matches[1].length > 0){
                profileVersionId = '/'+matches[1];
        var wtads = document.createElement('script');
        wtads.async = true;
        wtads.type = 'text/javascript';
        wtads.src = url+profileVersionId+'/pwt.js';
        var node = document.getElementsByTagName('script')[0];
        node.parentNode.insertBefore(wtads, node);
    <!--Wrapper Script ends here -->
<!-- A9 Script Start -->
     !function(a9,a,p,s,t,A,g){if(a[a9])return;function q(c,r){a[a9]._Q.push([c,r])}a[a9]={init:function(){q("i",arguments)},fetchBids:function(){q("f",arguments)},setDisplayBids:function(){},_Q:[]};A=p.createElement(s);A.async=!0;A.src=t;g=p.getElementsByTagName(s)[0];g.parentNode.insertBefore(A,g)}("apstag",window,document,"script","//");
         pubID: 'xxxx',
         adServer: 'googletag'
         slots: [{
             slotID: 'Div2',
             sizes: [[300, 250], [300, 600]]
             slotID: 'Div1',
             sizes: [[728 ,90]]
         timeout: 2e3 // Make Sure this timeout is less than or equal to OpenWrap TimeOut
     }, function(bids) {
         // Your callback method, in this example it triggers the first DFP (GAM) request for googletag's disableInitialLoad integration after bids have been set
             window.OWT.notifyExternalBiddingComplete(notifyId); // This will tell OpenWrap that all the external bidders have returned bid.
            // googletag.pubads().refresh(); No need to call refresh in callback as OpenWrap takes care of display.
    <!-- A9 Script End -->
    <script type="text/javascript">
        googletag.cmd.push(function() {
            var s1 = googletag.defineSlot('/15671365/DMDemo', [
                [728, 90]
            ], 'Div1').addService(googletag.pubads());
            s1.setTargeting('abc', 123);
            var s2 = googletag.defineSlot('/15671365/DMDemo1', [
                [300, 250],
                [300, 600]
            ], 'Div2').addService(googletag.pubads());
            s2.setTargeting('2abc', 123);
            notifyId = window.OWT.registerExternalBidders(['Div1', 'Div2']); // Notifies OpenWrap that there are some external bidders for which it has to wait before calling DFPGAM.
            // common targetings
            googletag.pubads().setTargeting('v', 'classifieds');
            googletag.pubads().setTargeting('article-id', '65207');
<body style='background-color:whitesmoke;'>
    <!-- DMDemo -->
    Adslot : /15671365/DMDemo
    <div id='Div1'>
        googletag.cmd.push(function() {
    <!-- DMDemo1 -->
    Adslot : /15671365/DMDemo1
    <div id='Div2'>
        googletag.cmd.push(function() {