Prebid.js adapter setup for video

Last updated on September 28, 2018

OpenX's adapter allows OpenX to participate as a demand source within the Prebid container solution using a video player. (http://prebid.org) This topic will guide you through adding OpenX's Prebid adapter into your existing Prebid implementation.

The OpenX adapter for Prebid.js supports in-streamAn ad that appears within video content. For example, a pre-roll ad attached to a YouTube video. video.

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 instructions for Setting up Prebid Video in DFP. Be sure to add the OpenX key-value pair values to your line items. The OpenX key-value pair value has the following format: oxb=size_bid.
  2. Provide answers to the following questions to OpenX:
    1. Which inventoryAd space available on a website or app. The basic unit of inventory for OpenX is an ad unit. 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. Select OpenX from Select 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. Adapters and DFP Video from Modules.
  4. Configure bidder: 'openx' using the properties in the table below.
    var videoAdUnit = {       
       code: 'video1',
       mediaTypes: {
          video : {
             playerSize: [640, 480],
             context: 'instream'
          }
       }, 
       bids: [{            
          bidder: 'openx',             
          params: {
             unit: '1611023124',
             delDomain: 'PUBLISHER-d.openx.net',
          }                      
       }]     
    };

    Property

    Type

    Description

    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'

    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: '1611023124'

    Required

    openrtb

    Object

    OpenRTB properties. OpenX only supports the following OpenRTB video object properties for use with Prebid (see the IAB's OpenRTB 2.5 specification):

    • mimes
    • minduration
    • maxduration
    • protocols
    • protocol
    • w
    • h
    • startdelay
    • linearity
    • sequence
    • battr
    • maxextended
    • minbitrate
    • maxbitrate
    • boxingallowed
    • playbackmethod
    • delivery
    • pos
    • api
    • companiontype
    • ext

    For example:

    openrtb: {
       "imp": [{
            "video": {
               "mimes":["video/mp4","video/x-flv"]
            }
        }]

    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. Register the ad unit and request bids.

    
    pbjs.que.push(function(){ 
       pbjs.addAdUnits(videoAdUnit);
       pbjs.setConfig({
          cache: { 
    		url: 'https://prebid.adnxs.com/pbc/v1/cache' 
          },
          userSync: {
    		iframeEnabled: true,
    		filterSettings: { 
    			iframe: {
    				bidders: ['openx'], 
    				filter: 'include'
    			}
    		}
          }
       }); 
       pbjs.requestBids({ 
          timeout: 1500, 
          bidsBackHandler: function(bids) {
             var videoUrl = pbjs.adServers.dfp.buildVideoUrl({
                adUnit: videoAdUnit,
                params: {
                   iu: '/12345678/DFP_ad_unit',
                   output: 'vast',
                   hl: 'en'
                }
             });
    
             invokeVideoPlayer(videoUrl); 
          } 
       }); 
    });
    
  7. Initialize your player. The following code example uses the JW Player video player as an example.
    
    var jwPlayerInstance = jwplayer('playerContainerJW');
    invokeVideoPlayer = function(url) {
       jwPlayerInstance.setup({
          file: 'enter video file or use jwPlayer license key',
          autostart: true,
          mute: true,
          advertising: {
             client: 'vast'
          }
       });
    
       jwPlayerInstance.on('beforePlay', function(){
          jwPlayerInstance.playAd(url);
       });
    }
  8. Send a test page to OpenX for review.
  9. After OpenX reviews it, deploy this implementation to all your production digital pages.

Full code sample

The following code example uses the JW Player video player. However, this solution supports any video player.

<html>
<head>
   <!-- prebid.js -->
   <script src="prebid.js" async=true></script>

   <!-- JWPlayer -->
   <script type="text/javascript" src="http://ssl.p.jwpcdn.com/player/v/8.3.5/jwplayer.js"> 
   </script>

   <script type="text/javascript"> 
      jwplayer.key="Enter your key";
   </script>
  
   <script>
      /* Prebid Video adUnit */

      var videoAdUnit = {
         code: 'video1',
         mediaTypes: {
            video: {
               playerSize: [640, 480],
               context: 'instream'
            }
         },
         bids: [{
            bidder: 'openx',
            params: {
               unit: '1611023124',
               delDomain: 'PUBLISHER-d.openx.net',
            }
         }]
      };
				
      var pbjs = pbjs || {};
      pbjs.que = pbjs.que || [];

      pbjs.que.push(function(){ 
         pbjs.addAdUnits(videoAdUnit);
         pbjs.setConfig({ 
            cache: { 
                url: 'https://prebid.adnxs.com/pbc/v1/cache' 
            }, 
            userSync: {
               iframeEnabled: true,
               filterSettings: { 
                  iframe: {
                     bidders: ['openx'], 
                     filter: 'include'
                  }
               }
            }
         });
         pbjs.requestBids({ 
            timeout: 1500, 
            bidsBackHandler: function(bids) {
               var videoUrl = pbjs.adServers.dfp.buildVideoUrl({
                  adUnit: videoAdUnit,
                  params: {
                     iu: '/90577858/test_ox_prebid_video',
                     output: 'vast',
                     hl: 'en'
                  }
               });
				
               invokeVideoPlayer(videoUrl); 
            } 
         }); 
      });
   </script>
</head>

<body>
   <div id='playerContainerJW' style='width:640px; height:480px; border:1px solid black;'>
   </div>

   <script>
      var jwPlayerInstance = jwplayer('playerContainerJW');

      invokeVideoPlayer = function(url) {
         jwPlayerInstance.setup({
            file: 'enter video file or jwPlayer license key',
            autostart: true,
            mute: true,
            advertising: {
               client: 'vast'
            }
         });

         jwPlayerInstance.on('beforePlay', function(){
            jwPlayerInstance.playAd(url);
         });
      }
   </script>
</body>
</html>
Fill out my online form.