Part 3: AdOps Setup (DFP)

We recommend to start with a easy setup to ensure a quick development. You can add more Line-Items and price granularity late on.

Creative Inventory Key-Values

Create the following key-values:

  • hb_bidder

  • hb_pd


Add a line item

In DFP, create a new order with your requested minimum price ($0.50 in this example).

Enter all of the inventory sizes that your website has.


Because header bidding partners return prices, set the Line Item Type to Price priority to enable them to compete on price.


Set the Rate to $0.50 (your minimum CPM) so that this line item will compete with your other demand sources.


Set Display Creatives to One or More since we’ll have one or more creatives attached to this line item.

Set Rotate Creatives to Evenly.


Choose the inventory that you want to run header bidding on.

By default, we will send the highest bid price to DFP using the keyword hb_pb and the bidder using keyword hb_bidder.

This line item will capture the bids in the range from $0.50 to $1 by targeting the keyword hb_pb set to 0.50 in the Key-values section.

You must enter the value to two decimal places, e.g., 1.50. If you don’t use two decimal places, header bidding will not work.


Add a Creative

Next, add a 3rd Party creative to this line item.

Choose the same advertiser we’ve assigned the line item to.

Note that this has to be a Third party creative. The “Serve in Safeframe” box has to be UNCHECKED

Copy this creative code snippet and paste it into the Code snippet box.


var w = window;
for (i = 0; i < 10; i++) {
  w = w.parent;
  if (w.pbjs) {
    try {
      w.pbjs.renderAd(document, '%%PATTERN:hb_adid%%');
    } catch (e) {

Make sure the creative is declared as "SSL compatible"


Override Creative-Size

Edit the just created creative, select "Size override", and select all sizes that you would like to run header-bidding on.


Attach the Creative to the Line Item

Next, let’s attach the creative to the line item you just created. Click into the Line Item, then the Creatives tab.

There will be yellow box showing each ad spot that you haven’t uploaded creatives for yet. Since you’ve already made the creatives, click the use existing creatives next to each size.


In the pop-up dialog that appears, click Show All to remove the default size filters and see the. Include the prebid creative and click Save.


Back in the line item, go into the Creatives tab again, and click into the creative you just added.

Then, in the creative’s Settings tab, override all sizes in the Size overrides field.

Save the creative and go back to the line item.

Duplicate Creatives

DFP has a constraint that one creative can be served to at most one ad unit in a page under GPT’s single request mode.

Let’s say your page has 4 ad units. We need to have at least 4 creatives attached to the line item. Therefore, we need to duplicate our creative 4 times.

Once that’s done, we have a fully functioning line item with 4 creatives attached.

Set additional targetings

If you want to run your header-bidding auction just on specific countries or devices you can set those targetings on line-level as well.