Prebid integration for Header Bidding

Introduction

vi has developed a Prebid Adapter, enabling publishers to integrate with vi for vi stories through Header Bidding, using Prebid.js as described on prebid.org

Download and implementation

To implement Header Bidding, follow the instructions on http://prebid.org/overview/getting-started.html.  When downloading the prebid.js file from http://prebid.org/download.html, make sure to include the viBidAdapter by checking the “vi” checkbox.

Parameters

The specific parameters required for setting up and running viBidAdapter are described in http://prebid.org/dev-docs/bidders.html#vi. Also have a look at https://github.com/prebid/Prebid.js/blob/master/modules/viBidAdapter.md.

The table below describes the Bid parameters in detail:

bid params

Name Scope Description Example
pubId required Publisher ID, provided by vi 'sb_test'
lang required Language of content, in ISO 639-1 language code format 'en-US'
cat required Content IAB category (top-level or subcategory), see List of IAB Categories 'IAB9-1'
bidFloor optional Lowest value of expected bid price 0.01

Example

Below is an example, based on the example code on http://prebid.org/dev-docs/getting-started.html, adjusted to show the viBidAdapter settings

<html>
<head>
  <!-- Prebid Config Section START -->
  <!-- Make sure this is inserted before your GPT tag -->
  <script> 
    var PREBID_TIMEOUT = 700;

    var adUnits = [{
        code: 'div-gpt-ad-1460505748561-0',
        sizes: [[300, 250]],
        bids: [{
            bidder: 'vi',
            params: {
                pubId: 'sb_test',
                lang: 'en-US',
                cat: 'IAB9-1',
                bidFloor: 0.01 //optional
            }
        }]
    }];

    var pbjs = pbjs || {};
    pbjs.que = pbjs.que || [];

    pbjs.que.push(function() {
        pbjs.enableSendAllBids();
    });

  </script>
  <!-- Prebid Config Section END -->
  
  <!-- Prebid Boilerplate Section START. No Need to Edit. -->
  <script type="text/javascript" src="//acdn.adnxs.com/prebid/not-for-prod/1/prebid.js" async></script>
  <script>
    var googletag = googletag || {};
    googletag.cmd = googletag.cmd || [];
    googletag.cmd.push(function() {
        googletag.pubads().disableInitialLoad();
    });

    pbjs.que.push(function() {
        pbjs.addAdUnits(adUnits);
        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>
  <!-- Prebid Boilerplate Section END -->

  <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('/19968336/header-bid-tag-0', [[300, 250]], 'div-gpt-ad-1460505748561-0').addService(googletag.pubads());

        googletag.pubads().enableSingleRequest();
        googletag.enableServices();
    });
  </script>
</head>

<body>
<h2>Prebid.js Test</h2>

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

</body>
</html>