Show Prebid Ads on AMP Pages
This page has instructions for showing ads on AMP pages using Prebid.js.
For more information about AMP RTC, see:
- How Prebid on AMP Works
- Prebid Server AMP Endpoint
- Prebid Server Stored Bid Requests
- AMP RTC Overview
- AMP RTC Publisher Integration Guide
For ad ops setup instructions, see Setting up Prebid for AMP in DFP.
- Related Topics
To set up Prebid to serve ads into your AMP pages, you’ll need:
- An account with a Prebid Server instance
- One or more Prebid Server Stored Bid Requests. A Stored Bid Request is a partial OpenRTB JSON request which:
- Specifies properties like timeout and price granularity
- Contains a list of demand partners and their respective parameters
- An AMP page containing at least one amp-ad element for an AMP ad network that supports Fast Fetch and AMP RTC
- Prebid Server Stored Request: This is the Prebid Server Stored Bid Request.
- AMP content page: This is where your content lives.
- HTML Creative: This is the creative your Ad Ops team puts in your ad server.
- User Sync in AMP: This is the
amp-iframepixel that must be added to your AMP page to sync users with Prebid Server.
Prebid Server Stored Request
You will have to create at least one Stored Request for Prebid Server. Valid Stored Requests for AMP pages must contain an
imp array with exactly one element. It is not necessary to include a
tmax field in the Stored Request, as Prebid Server will always use the smaller of the AMP default timeout (1000ms) and the value passed via the
timeoutMillis field of the
amp-ad.rtc-config attribute (explained in the next section).
An example Stored Request is given below:
AMP content page
amp-ad elements in the page body need to be set up as shown below, especially the following attributes:
data-slot: Identifies the ad slot for the auction.
rtc-config: Used to pass JSON configuration data to Prebid Server, which handles the communication with AMP RTC.
vendorsis an object that defines any vendors that will be receiving RTC callouts (including Prebid Server) up to a maximum of five. The list of supported RTC vendors is maintained in callout-vendors.js.
timeoutMillisis an optional integer that defines the timeout in milliseconds for each individual RTC callout. The configured timeout must be greater than 0 and less than 1000ms. If omitted, the timeout value defaults to 1000ms.
This is the creative that your Ad Ops team needs to upload to the ad server (it’s also documented at Setting up Prebid for AMP in DFP).
You can always get the latest version of the creative code below from the AMP example creative file in our GitHub repo.
To properly sync user IDs with Prebid Server, the
amp-iframe pixel below should be added to your AMP pages. As of now, only image pixels (those returned with “type”: “redirect”) are supported.
Iframes must be either 600px away from the top or not within the first 75% of the viewport when scrolled to the top – whichever is smaller. For more information on this, see amp-iframe