Troubleshooting Prebid.js

This guide will provide several sequential steps to help troubleshoot your Prebid.js integration.

Prebid.org does not support any version of Prebid.js prior to version 1.0.


Check your Prebid version

The open source code in Prebid.js can change frequently. To see what version of Prebid.js you are using, open your browser console and type pbjs.version;.

Check Prebid.js version


Turn on Prebid.js debug messages

Add pbjs_debug=true to the end of your page’s URL. For example:

/pbjs_demo.html?pbjs_debug=true

This will add two types of messages to your browser’s developer console:

  1. Prebid.js suppresses Javascript errors in the normal mode to not break the rest of your page. Adding the pbjs_debug parameter will expose the Javascript errors.
  2. You’ll find additional debug messages. Filter the messages by string MESSAGE:. For example:

Prebid.js message log

Message Description
Calling bidder When Prebid.js sends out bid requests, this message is logged
Set key value for placement After all the bids came back, or when timeout is reached, prebid.js will set keyword targeting for the defined ad units.
Calling renderAd If a header bidding bid wins the ad server’s auction, prebid.js will render the winning bid’s creative.

Verify your config

In your browser Console tab, insert pbjs.getConfig() in the command line. Check for basic setup in the output, including:

  • selected timeout,
  • selected priceGranularity.

Verfiy your config


Turn on your ad server’s developer console

The ad server’s developer console usually provide information such as targeting, latency, and key events logging. For example, here is a screenshot of DFP’s GPT developer console logs:

Prebid.js Debug Console


Delay the ad server call so key-values can be set

Make sure that you delay any calls to the ad server. This allows all of the key-values to be set before the auction in the ad server occurs.

Within DFP, this is achieved by adding the following code to your page. It should be called before any of the ad server code to make sure it runs first.

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

Verify ad unit setup

In your browser Console tab, insert pbjs.adUnits in the command line. Check for correctly implemented ad units on-page in the output, including correct bidder, media type, sizes.

Verify ad unit setup


Check the ad units on the page

Make sure the ad units configured for Prebid.js match up with the ad units that have been set up in your ad server.

You can review what ad units have been configured for Prebid by opening your browser console and typing pbjs.getBidResponses();. This also shows what bids have been returned from each of the bidder partners in chronological order as shown in the screenshot below:

Check ad units

Expanded view of bid responses

Check ad units

To see all of the winning bids, open your browser console and type pbjs.getAllWinningBids();.

Keep in mind that any bid responses that come back after the timeout you configured during setup will not be sent to the ad server.

You can also print this data to the console in table format for easier reading.


Modify bid responses for testing

Using pbjs.setConfig({debugging:{ ... }}) from the javascript console, it is possible to override and filter bids as they come in. When this type of debugging is enabled it will persist across page loads using sessionStorage.

This allows for easy testing of pages that immediately start auctions (most pages), but also means you need to remember to deactivate debugging when you are done (or clear your local storage / use incognito mode when testing).

// Filtering bidders
javascript console> pbjs.setConfig({
  debugging: {
    enabled: true,                     // suppresses bids from other bidders
    bidders: ['bidderA', 'bidderB']
  }
});

// Overwriting bid responses for all bidders
javascript console> pbjs.setConfig({
  debugging: {
    enabled: true,
    bids: [{
      cpm: 1.5
    }]
  }
});

// Overwriting bid responses for a specific bidder and adUnit code (can use either separately)
javascript console> pbjs.setConfig({
  debugging: {
    enabled: true,
    bids: [{
      bidder: 'bidderA',
      adUnitCode: '/19968336/header-bid-tag-0',
      cpm: 1.5
    }]
  }
});

// Disabling debugging
javascript console> pbjs.setConfig({
  debugging: {
    enabled: false
  }
});

List your Bids and Bidders

Open your browser console and type pbjs.getBidResponses(); to see a list of the ad units that have been configured. This also shows what bids have been returned from each of the bidder partners in chronological order as shown in the screenshot below.

To see all of the winning bids, open your browser console and type pbjs.getAllWinningBids();.

Keep in mind that any bid responses that come back after the timeout you configured during setup will not be sent to the ad server.

You can also print this data to the console in table format for easier reading.

pbjs.getBidResponses() in browser console


See all bids in the console

To print information about all of the bids that come in to the Console on any page that is running Prebid.js, follow these steps.

Open the Chrome Dev Tools. In the Sources tab, next to Content Scripts, click the » button and you can add Snippets:

View Snippets in Dev Tools


Right-click to add a New snippet:

Add New Snippet in Dev Tools


Paste in the following code using Control-V (or Command-V on Mac), and give the snippet a name, such as ‘show-all-bids’:

(function() {
  function forEach(responses, cb) {
    Object.keys(responses).forEach(function(adUnitCode) {
      var response = responses[adUnitCode];
      response.bids.forEach(function(bid) {
        cb(adUnitCode, bid);
      });
    });
  }
  var winners = pbjs.getAllWinningBids();
  var output = [];
  forEach(pbjs.getBidResponses(), function(code, bid) {
    output.push({
      bid: bid,
      adunit: code,
      adId: bid.adId,
      bidder: bid.bidder,
      time: bid.timeToRespond,
      cpm: bid.cpm,
      msg: bid.statusMessage,
      rendered: !!winners.find(function(winner) {
        return winner.adId==bid.adId;
      })
    });
  });
  forEach(pbjs.getNoBids && pbjs.getNoBids() || {}, function(code, bid) {
    output.push({
      msg: "no bid",
      adunit: code,
      adId: bid.bidId,
      bidder: bid.bidder
    });
  });
  if (output.length) {
    if (console.table) {
      console.table(output);
    } else {
      for (var j = 0; j < output.length; j++) {
        console.log(output[j]);
      }
    }
  } else {
    console.warn('NO prebid responses');
  }
})();


Right-click the snippet and choose Run:

Run a Snippet in Dev Tools


Check the output in Console to see the bids:

See Snippet Output in Dev Tools


See all winning bids in the console

To print information about all of the winning bids that come in to the Console on any page that is running Prebid.js, follow these steps.

Open the Chrome Dev Tools. In the Sources tab, next to Content Scripts, click the » button and you can add Snippets:

View Snippets in Dev Tools


Right-click to add a New snippet:

Add New Snippet in Dev Tools


Paste in the following code using Control-V (or Command-V on Mac), and give the snippet a name, such as ‘show-all-winning-bids’:

var bids = pbjs.getHighestCpmBids();
var output = [];
for (var i = 0; i < bids.length; i++) {
    var b = bids[i];
    output.push({
        'adunit': b.adUnitCode, 'adId': b.adId, 'bidder': b.bidder,
        'time': b.timeToRespond, 'cpm': b.cpm
    });
}
if (output.length) {
    if (console.table) {
        console.table(output);
    } else {
        for (var j = 0; j < output.length; j++) {
            console.log(output[j]);
        }
    }
} else {
    console.warn('No prebid winners');
}


Right-click the snippet and choose Run:

Run a Snippet in Dev Tools


Check the output in Console to see the bids (note that this screenshot shows the output from “see all bids” but they’re very similar):

See Snippet Output in Dev Tools


Verify ad server targeting

After the auction on page has occurred, Prebid.js will set key-value targeting for the ad server for those bids that have been returned before the timeout you configured during setup.

To see what values Prebid.js intends to send to the ad server, open your browser console and type pbjs.getAdserverTargeting(); as shown below:

Check for the list of key-values for the bidder.

Verify ad server targeting


Check the Ad Server’s Auction

After the Prebid auction has occurred and key-values have been set for the ad server, the ad server will use the line items targeting those key-values within its auction.

If you’re using DFP, you can verify this by using the Google Publisher Console, which can be accessed as follows:

  • Open your browser’s console and type googletag.openConsole();

  • Append googfc as a query parameter to the URL. Then, click the Delivery Diagnostics option to reveal most of the information described below.

To make sure your ad server is set up correctly, answer the following questions:

  • How many ads have been fetched for an ad unit? Ideally, only 1 ad will be requested on page load. If not, check for unnecessary extra calls to the ad server in your page’s source code.

    Google Publisher Console Ad fetch count

  • Are the key-values being set in the ad server? If not, review your page’s source code to ensure that the Prebid auction completes before sending the key-value targeting to the ad server.

    DFP Delivery Troubleshooting

  • Has the ad server order been activated? If not, you’ll have to activate the order to see Prebid-delivered ads.

  • Are there other higher priority campaigns running within your ad server? Higher priority campaigns will prevent Prebid ads with a higher CPM bid from winning in the ad server’s auction. For testing purposes, you may want to pause these campaigns or have them excluded when the prebid key values are present.

  • Is there other remnant inventory in the ad server with a higher CPM that is winning? To test for this, you may want to use a test creative set up within a bidder partner that has a high CPM or create artificial demand with a bidCPMadjustment.

  • Have you set up all of the line items in the ad server to match the setPriceGranularity setting within Prebid.js? All of the line items that correspond to your price granularity settings must be set up in your ad server. When there are gaps in the price granularity of your line item setup, bids will be reduced according to the size of the gap. For example, with dense granularity, a $3.32 bid will be sent to the ad server as $3.30.


Look for the Winning Bid

When a prebid line item wins the ad server’s auction, a renderAd event will be logged in the browser console. To see this event, you need to do either of the following before the auction:

  • Have typed pbjs.logging=true into your your browser console

  • Appended pbjs_debug=true as a query parameter to the URL

When this event is logged, it shows that Prebid.js has requested to render the ad from the winning bidder partner, and that this partner’s bid has won both the Prebid and ad server auctions.

renderAd event in browser console