You are here: Publishers > OpenX Bidder > Advanced implementation for OpenX Bidder

Advanced implementation for OpenX Bidder

Last updated on December 23, 2016

After you have reached out to your account manager, you and your OpenX representative will use the following instructions to guide you through the advanced implementation of OpenX BidderOpenX's header bidding solution. Bidder enables publishers to realize the true value of their direct and indirect inventory in real time. "Bidder" can also mean a program designed to bid in real time on inventory in the OpenX Ad Exchange..

In this topic we will:

Implementation process

  1. Provide a list of any special targeting or block lists to your OpenX representative.
  2. Using the global variable, OX_dfp_ads, define the ad slots for which you plan to fetch prices. The properties of the OX_dfp_ads variable are shown below.
    
    var OX_dfp_ads = [
       [DFP_AdUnit, [size_array], div, {targetingMap}]
    ];

    Property

    Description

    Type

    Example

    Required?

    DFP_AdUnit

    DFP ad unitIn OpenX, the smallest inventory component that represents the space on a site where ads display. name

    String'/12345/abc/zone1'

    Yes

    [size_array]

    Available sizes for the specified ad unit

    String (Array)['160x600','300x600']

    Yes

    div

    div id that will be called in the googletag.display call

    Stringdiv-gpt-ad-123456789-1

    Yes

    {targetingMap}

    Targeting map for specific key-value pairs

    String or null{'pos':['atfAbove the fold. ATF ads are visible on the screen without needing to scroll. See screen location.']}

    No


  3. Wrap the Google PublisherIn OpenX, an account type that represents a business with ad space to sell. Tag (GPT) JavaScript library load in the oxDone function. The oxDone function loads the GPT JavaScript library after OpenX has returned with price support. In case the OpenX JSTAG library fails to load, we provided a fail-safe that will call the oxDone method after 2.5 seconds.
  4. 
    function oxDone() {
       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); 
    }
    setTimeout(function() {
       if (!('OX' in window || 'oxhbjs' in window)) {
          oxDone()
       }
    },2500);

    Note: Note: If gpt.js is loaded synchronously, initialize the window.googletag variable as below.

    
    window.googletag = window.googletag || {};
    window.googletag.cmd = window.googletag.cmd || [];


  5. Load the OpenX JavaScript Tag (JSTAG) library. The PUBLISHER, NETWORKCODE and SITEAn OpenX component that represents top-level domains or sub-domains and is used to organize ad units. Sites enable you to target and report on inventory performance. placeholders within openx.src are provided by your OpenX representative.
  6. 
    (function() {
       var openx = document.createElement("script"),
       useSSL = "https:" == document.location.protocol, 
       node = document.getElementsByTagName("script")[0];
       openx.async = true;
       openx.type = "text/javascript";
       openx.src = (useSSL ? "https:" : "http:") + 
    	"//PUBLISHER-d.openx.net/w/1.0/jstag?nc=NETWORKCODE-SITE"; 
       node.parentNode.insertBefore(openx, node);
    })();

  7. Add OpenX key values to your GPT ad slots using the OX.dfp_bidder.setOxTargeting function. The OX.dfp_bidder.setOxTargeting function will dynamically add the OpenX key-value pair for each ad slotThe area on a web page set aside for the display of ads. defined in OX_dfp_ads. For more information about this and other OX.dfp_bidder methods, refer to the Bidder advanced functions topic.
  8. 
    googletag.defineSlot('/12345/abc/zone1', [728, 90], 
      'div1').addService(googletag.pubads()); 
    googletag.defineSlot('/12345/abc/zone2', [[160, 600],[300,600]], 
      'div2').addService(googletag.pubads()); 
    OX.dfp_bidder.setOxTargeting();
    googletag.enableServices();	
  9. [Optional] If your site incorporates refreshes, be sure to use OX.dfp_bidder.refresh().
  10. Check your advanced implementation of the OpenX Bidder.
  11. Send your test page to your OpenX representative for review.
  12. After OpenX review, deploy this implementation to all your production digital pages.

Code sample

Below is an example of a test page created using the steps outlined above in the Process section.

Note: You can view a live example of the code below on this test page.



<head>				
<script>
var googletag = googletag || {};
googletag.cmd = googletag.cmd || [];				

/*
From step #2 above, define the ad slots for which you plan to fetch prices. 
OX_dfp_ads is an array that pre-requests ad units on the page.  
The ad units that are define should be a 1:1 match of the defineSlots on each page.
*/
var OX_dfp_ads = [
   ['/90577858/openx_demo_bidder7281',
   ['728x90'],
   'div-gpt-ad-1458590870727-4'],
];

/*
From step #3 above, wrap the GPT load in the oxDone function.
The timeout within this function can be changed by the publisher.  
GPT will run if OX isn't loaded on the page by the designated timeout.
*/
function oxDone() {
   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);
}
setTimeout(function() {
   if (!('OX' in window || 'oxhbjs' in window)) {
      oxDone()
   }
}, 2500);
				
//From step #4, load the OpenX JSTAG library.
(function () {
   var openx = document.createElement("script"),
   useSSL = "https:" == document.location.protocol,
   node = document.getElementsByTagName("script")[0];
   openx.async = true;
   openx.type = "text/javascript";
   openx.src = (useSSL ? "https:" : "http:") + 
     "//oxdemo-d.openxenterprise.com/w/1.0/jstag?nc=90577858-oxbidder2015";
   node.parentNode.insertBefore(openx, node);
})();
				
googletag.cmd.push(function() {
   googletag.defineSlot('/90577858/openx_demo_bidder7281', [728, 90], 
     'div-gpt-ad-1458590870727-4').addService(googletag.pubads());
				
   //From step #5, add the OpenX key values.
   OX.dfp_bidder.setOxTargeting();
   googletag.pubads().enableSingleRequest();
   googletag.enableServices();
});
</script>
</head>

Feedback form