Prebid.js adapter setup for web

Last updated on November 15, 2018

This document will guide you through the following:

Note: You must be using Prebid.js version 1.9.0 or later. For GDPR support, you must use version 1.11 or later.

Implementation

  1. Follow Prebid's Step by step guide to DFP setup.
  2. Provide answers to the following questions to OpenX:
    1. Which display ad sizes do you plan to use?
    2. Are you using other adapters?

    Also, work with OpenX to ensure OpenX is listed correctly in your ads.txt file.

  3. Customize and download your prebid.js code with the OpenX bidder adapter selected.
  4. Configure bidder: 'openx' using the properties in the table below.
      
    var adUnits = [{       
       code: 'div-gpt-ad-1438287399331-0',
       mediaTypes: {
          banner: {
             sizes: [[728, 90]]}
          },       
       bids: [{             
          bidder: 'openx',             
    	  params: {
             unit: '1611023122',               
             platform: '1cabba9e-cafe-3665-beef-f00f00f00f00',
             customFloor: 1.50,
             customParams: {
                key1: 'v1',
                key2: ['v2', 'v3']
             }            
          }           
       }]     
    }];

    Property

    Type

    Description

    Required?

    platform

    String

    OpenX platform ID provided by OpenX.

    For example: 1cabba9e-cafe-3665-beef-f00f00f00f00

    Either delDomain or platform is required

    delDomain

    String

    OpenX delivery domainThe domain on which ads will be served for your OpenX inventory. OpenX Partner Services provide this to you so you can set up your implementation. For example: PUBLISHER-d.openx.net. provided by OpenX.

    For example: 'PUBLISHER-d.openx.net'

    Either delDomain or platform is required

    unit

    String

    OpenX ad unitThe smallest inventory component that represents the space on a site where ads display. ID provided by OpenX.

    For example: '1611023122'

    Required

    customFloor

    Number

    Minimum price in USD. customFloor applies to a specific unit.

    For example, use the following value to set a $1.50 floorThe minimum price a publisher is willing to accept for a given impression.: 1.50

    Optional

    customParams

    Object

    User-defined targeting key-value pairs. customParams applies to a specific unit.

    For example: {key1: 'v1', key2: ['v2','v3']}

    Optional

  5. Add the following code to enable user syncing. OpenX strongly recommends enabling user syncing through iframes, which is turned off by default in Prebid.js version 0.34.0+. This functionality improves DSPDemand-side platform, a platform or provider that allows advertisers to manage multiple ad exchange and data exchange accounts through one interface, often in real time. user match rates and increases the OpenX bid rate and bid price. Make sure to call pbjs.setConfig() only once. Note that Prebid.js version 1.15 implements a different way to enable user syncing through iframes than previous versions. The code below works for both implementations.
    
    pbjs.setConfig({ 
    	userSync: {
    		iframeEnabled: true,
    		filterSettings: { 
    			iframe: {
    				bidders: ['openx'],
    				filter: 'include'
    			}
    		}
    	}
    });
  6. Send a test page to OpenX for review.

Full code sample


<html>
<head>
   <script> 
      var PREBID_TIMEOUT = 1500;
      var adUnits = [{       
         code: 'div-gpt-ad-1438287399331-0',       
         sizes: [[728, 90]],
         mediaTypes: {banner: {}},       
         bids: [{             
            bidder: 'openx',             
            params: {
               unit: '1611023122',               
               platform: '1cabba9e-cafe-3665-beef-f00f00f00f00',
               customFloor: 1.50,
               customParams: {
                  key1: 'v1',
                  key2: ['v2', 'v3']
               }            
            }           
         }]     
      }];
    
      var pbjs = pbjs || {};
      pbjs.que = pbjs.que || [];

   </script>

   <script>
      var googletag = googletag || {};googletag.cmd = googletag.cmd || [];
      googletag.cmd.push(function() {
         googletag.pubads().disableInitialLoad();
      });

      pbjs.que.push(function() {
         pbjs.addAdUnits(adUnits);
         pbjs.setConfig({
            priceGranularity: "dense",		 
            userSync: {
               iframeEnabled: true,
		filterSettings: { 
			iframe: {
				bidders: ['openx'],
				filter: 'include'
			}
		}	
            }
	  });
         pbjs.requestBids({
            bidsBackHandler: sendAdserverRequest
         });
      });

      function sendAdserverRequest() {
         if (pbjs.adserverRequestSent) return;
         pbjs.adserverRequestSent = true;
         googletag.cmd.push(function() {
            pbjs.que.push(function() {
               pbjs.setTargetingForGPTAsync();
               googletag.pubads().refresh();
            });
         });
      }

      setTimeout(function() {
         sendAdserverRequest();
      }, PREBID_TIMEOUT);

   </script>

   <script>
      (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>
      googletag.cmd.push(function () {
         googletag.defineSlot('/90577858/prebid_auid', [[728, 90]], 'div-gpt-ad-1438287399331-0').addService(googletag.pubads());
         googletag.pubads().enableSingleRequest();
         googletag.enableServices();
      });
   </script>
</head>

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

</body>
</html>

Best practices

Fill out my online form.