Link Search Menu Expand Document

PDF

Prebid.js Adapter Setup for Web

Publishers

Last updated on November 15, 2018


This page guides you through the Prebid.js adapter for web implementation.


on this page


Implementation

Prior to starting consider the following requirements:

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

To implement Prebid.js adapter for web:

  1. Follow Prebid’s Step by step guide to DFP setup.

  2. Provide answers to the following questions to OpenX:

    a. Which display ad sizes do you plan to use?

    b. Are you using other adapters?

    In addition, 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']
             }
          }
       }]
    }];
    
    PropertyTypeDescriptionRequired?
    platformstringOpenX platform ID provided by OpenX.

    For example: 1cabba9e-cafe-3665-beef-f00f00f00f00
    Either delDomain or platform is required
    delDomainstringOpenX delivery domain provided by OpenX.

    For example: PUBLISHER-d.openx.net
    Either delDomain or platform is required
    unitstringOpenX ad unit ID provided by OpenX.

    For example: 1611023122
    Required
    customFloornumberMinimum price in USD. customFloor applies to a specific unit.

    For example, use the following value to set a $1.50 floor: 1.50
    Optional
    customParamsobjectUser-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 DSP 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

Click to expand code sample
<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

Some best practices are listed below.


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. If you have five DFP ads on the page, you should request five ads in your Prebid.js config.


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

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

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

Use one of the two approaches below to define buckets:


Within your instance of DFP, create the hb_bidder key and a unique value for each header bidding partner

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 values for each header bidding partner, you will be able to analyze the performance of your header bidding partners.

Use the hb_bidder key and a unique value for each header bidding partner to define key-values.

You should follow this best practice even if you are using only Top Bid.


Limit your header bidding partner participation to three or four at a time

Having 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.