Learn

← Track B: Client-Side Prebid.js
L2

B2

Ad units and the OpenRTB shape of a request

In this lesson you will
  • Author an adUnit: code, mediaTypes (banner / video / native), sizes / sizeConfig, bids[].
  • Map ad-unit fields to the OpenRTB imp object.
  • Understand ortb2 / ortb2Imp first-party data.

Before any bidder can bid, you have to describe what you are selling: this slot, these sizes, these formats. In Prebid that description is an adUnit, and it maps almost one-to-one onto the OpenRTB request every exchange already speaks.

An adUnit has three core parts: a code (which matches your ad-server slot), mediaTypes (banner, video, or native, with their sizes), and bids[] (the bidders you want, each with its params).

{
  code: 'div-leaderboard',
  mediaTypes: { banner: { sizes: [[728, 90], [970, 250]] } },
  bids: [
    { bidder: 'rubicon',  params: { accountId: '1', siteId: '2', zoneId: '3' } },
    { bidder: 'pubmatic', params: { publisherId: '156209', adSlot: 'leaderboard' } },
  ],
}
A two-bidder banner ad unit

How it becomes an OpenRTB request

Prebid turns each adUnit into an OpenRTB imp (impression) object: the sizes become banner.format, the mediaTypes become the imp’s media objects. The ortb2 and ortb2Imp fields let you attach first-party data (page context, audience signals) to the request, which good bidders use to value the impression.

Quick check

An advertiser only buys 300x250, but your adUnit lists only [728, 90]. Will they bid?

Note

Each bidder you add here should also be authorized in the page’s ads.txt. Track B3 and the Inspect tool make that connection.

Key concepts
adUnit (code, mediaTypes, sizes, bids[])OpenRTB imp mappingortb2 / ortb2Imp first-party data
Going deeper

To really lock this in: write a valid two-bidder banner ad unit from a spec, then find the bug in a malformed one.

Where this leads
PRACTICE

Proposed ad-unit builder.

DEBUG

Proposed "no bids because the size was never requested" reproduction.

Bidcliq Academy · B2: Ad units and the OpenRTB shape of a request