You are here: Publishers > Header bidding solutions > Third-party containers > Prebid.js adapter

Prebid.js adapter

Last updated on June 14, 2017

Prebid.js is a free and open source library for publishers to quickly implement header biddingA monetization tool that exposes each impression to programmatic demand before calling the ad server. This lets publishers realize the true value of their direct and indirect inventory in real time.. The OpenX Adapter allows OpenX to participate as a demand source within this solution. (http://prebid.org)

This topic will guide you through the following topics:

Note: You must be using Prebid.js version 0.14.0 or later.

Process

  1. Provide answers to the following questions to your OpenX representative:
    1. What bid buckets do you plan to use?
    2. Which ad unitThe smallest inventory component that represents the space on a site where ads display. sizes do you plan to use?
    3. Are you sending all keys via the pbjs.enableSendAllBids() function?
  2. Add the unit and delDomain values provided by your OpenX representative.
    
    //Register OpenX bidder tag ID   
    pbjs.que.push(function() {     
       var adUnits = [{       
          code: 'div-gpt-ad-1438287399331-0',       
          sizes: [[300, 250]],       
          bids: [{             
             bidder: 'openx',             
    	     params: {
                unit: '538xxxxxx',               
                delDomain: 'clientname-d.openx.net'            
             }           
          }]     
    }];
  3. Add the following code inside the pbjs.bidderSettings code to allow OpenX to pass key-value pairs to DFP. See the Prebid.js documentation for details. If standard OpenX bid buckets are used, please refer to the Standard OpenX bid bucket code.

    
    openx: { 	
       alwaysUseBid: true, 	
       adserverTargeting: [{ 	
          key: "oxb", 	
          val: function(bidResponse) {     	
             var bid;     	
             if (bidResponse.cpm < 20) {            
                //Penny Bid Buckets         	
                bid = ((Math.floor(bidResponse.cpm * 100) / 100) * 100).toFixed(0);     	
             } else {            
                //Twenty dollar bucket         	
                bid = "2000";     	
             }     	
             //Returns creativeSize_bidBucket as the value     	   
             return bidResponse.width + "x" bidResponse.height + "_" + bid; 
          }
       }]
    }
  4. If all keys are not being sent via the pbjs.enableSendAllBids() function, please refer to Additional metrics.
  5. Add the OpenX key-value pair values to DFP. The OpenX key-value pair value has the following format: oxb=size_bid.

    Note: Steps 3-5 give OpenX visibility into OpenX line itemThe primary unit of execution for an order, which represents a specific inventory purchase and the required conditions for ad delivery. performance. With this information, OpenX can make bid floorThe minimum price a publisher is willing to accept for a given impression. and targeting adjustment suggestions.

  6. If you are using more than one bidder partner in your prebid.js, please turn on the random bidder rotation feature.
  7. Create line items and set line item targeting in DFP for each bid bucket using the Prebid.js DFP documentation.
  8. Send a test page to your OpenX representative for review.

Standard OpenX bid bucket code

The following code should be used with standard OpenX bid buckets.


openx: {
   alwaysUseBid: true,
   adserverTargeting: [{
      key: "oxb",
      val: function(bidResponse) {
         var bid;
         if (bidResponse.cpm < 1) {
            bid = ((Math.floor(bidResponse.cpm * 20) / 20) * 100).toFixed(0);
         } else if (bidResponse.cpm < 5) {
            bid = ((Math.floor(bidResponse.cpm * 10) / 10) * 100).toFixed(0);
         } else if (bidResponse.cpm < 20) {
            bid = ((Math.floor(bidResponse.cpm * 2) / 2) * 100).toFixed(0);
         } else {
            bid = "2000";
         }
         return bidResponse.width + "x" + bidResponse.height + "_" + bid;
      }
   }]
}

Additional metrics

If the pbjs.enableSendAllBids() function is not being used to send all keys, use the following steps to add the ox_pb_won key to the prebid.js.

  1. Add the following code to the standard section inside the pbjs.bidderSettings code.
  2. 
    {
       key: "ox_pb_won",
       val: function (bidResponse) {
          if (bidResponse.bidderCode.indexOf('openx') !== -1) {
             return "true";
          }
          return "false";
       }
    }
    The following example illustrates the placement within the prebid.js.
    
    pbjs.bidderSettings = {
       standard: {
          alwaysUseBid: false,
          adserverTargeting: [{
             key: "hb_bidder",
             val: function(bidResponse) {
                return bidResponse.bidderCode;
             }
          }, {
             key: "hb_adid",
             val: function(bidResponse) {
                return bidResponse.adId;
             }
          }, {
             key: "hb_pb",
             val: function(bidResponse) {
                return bidResponse.pbMg;
             }
          }, {
             key: "hb_size",
             val: function(bidResponse) {
                return bidResponse.size;
             }
          }, {
             key: "ox_pb_won",
             val: function(bidResponse) {
                if (bidResponse.bidderCode.indexOf('openx') !== -1) {
                   return "true";
                }
                return "false";
             }
          }]
       }
    }
  3. Add the following OpenX key and values provided in the table below in DFP.
    KeyValues
    ox_pb_won

    true

    false

Best practices

Ensure the number of ad slots requested in the prebid.js code matches the number of ads on the page.

Instead of reading the slots on the page, Prebid.js solicits bid requests based on the bidders and slots configured. So, if you have 5 DFP ads on the page, you should request 5 ads in your prebid.js config.

Make sure that your DFP line items match the bucketing in your prebid.js code.

If you have line items in DFP at $0.10 increments up to $20, make sure that the code on the page rounds into $0.10 buckets and stops at $20.

Use one of the three approaches below to define buckets:

Create key values for hb_bidder inside DFP even if you are using only Top Bid.

If you have more than one header bidding partner, using only the hb_pb key to target a single Prebid order does not allow you to pull reports on the performance of each partner. By creating the hb_bidder key and individual key values for each header bidding partner, you will be able to analyze the performance of your header bidding partners.

You can create the hb_bidder key and values using the steps below:

  1. Login into DFP
  2. Click on InventoryAd space available on a website or app. The basic unit of inventory for OpenX is an ad unit. Tab
  3. Create Key
  4. Enter hb_bidder
  5. Create values for each of your header bidding partners

Limit your header bidding partner participation to 3-4 at a time

More header bidder partners does not equal higher revenue. Due to increased page load and browser overhead, too many header bidding partners can potentially cause revenue loss due to the extra processing.

Feedback form