Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update load-cookie documentation #5193

Merged
merged 11 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 55 additions & 56 deletions dev-docs/show-prebid-ads-on-amp-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ sidebarType: 2
---

# Prebid AMP Implementation Guide

{: .no_toc}

This page has instructions for showing ads on Accelerated Mobile Pages (AMP) using Prebid.js.
Expand All @@ -15,37 +14,37 @@ Through this implementation, [Prebid Server][PBS] fetches demand and returns key

For more information about AMP RTC, see:

* [Prebid Server and AMP](/prebid-server/use-cases/pbs-amp.html)
* [Prebid Server AMP Endpoint Technical Documentation](/prebid-server/endpoints/openrtb2/pbs-endpoint-amp.html)
* [Prebid Server Stored Bid Requests](https://github.com/prebid/prebid-server/blob/master/docs/developers/stored-requests.md#stored-bidrequests)
* [AMP RTC Overview](https://github.com/ampproject/amphtml/blob/master/extensions/amp-a4a/rtc-documentation.md)
* [AMP RTC Publisher Integration Guide](https://github.com/ampproject/amphtml/blob/master/extensions/amp-a4a/rtc-publisher-implementation-guide.md)
- [Prebid Server and AMP](/prebid-server/use-cases/pbs-amp.html)
- [Prebid Server AMP Endpoint Technical Documentation](/prebid-server/endpoints/openrtb2/pbs-endpoint-amp.html)
- [Prebid Server Stored Bid Requests](https://github.com/prebid/prebid-server/blob/master/docs/developers/stored-requests.md#stored-bidrequests)
- [AMP RTC Overview](https://github.com/ampproject/amphtml/blob/master/extensions/amp-a4a/rtc-documentation.md)
- [AMP RTC Publisher Integration Guide](https://github.com/ampproject/amphtml/blob/master/extensions/amp-a4a/rtc-publisher-implementation-guide.md)

{% capture tipNote %}
For ad ops setup instructions, see [Google Ad Manager with Prebid Step by Step](/adops/step-by-step.html).
{% endcapture %}

{% include alerts/alert_note.html content=tipNote %}

* TOC
- TOC
{:toc }

## Prerequisites

To set up Prebid to serve ads into your AMP pages, you'll need:

* An account with a [Prebid Server][PBS] instance
* One or more Prebid Server Stored Bid Requests. A Stored Bid Request is a partial OpenRTB JSON request which:
* Specifies properties like currency, schain, price granularity, etc.
* 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
- An account with a [Prebid Server][PBS] instance
- One or more Prebid Server Stored Bid Requests. A Stored Bid Request is a partial OpenRTB JSON request which:
- Specifies properties like currency, schain, price granularity, etc.
- 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

## Implementation

* [Prebid Server Stored Request](#prebid-server-stored-request): This is the Prebid Server Stored Bid Request.
* [AMP content page](#amp-content-page): This is where your content lives.
* [HTML Creative](#html-creative): This is the creative your Ad Ops team puts in your ad server.
* [User Sync in AMP](#user-sync): This is the `amp-iframe` pixel that must be added to your AMP page to sync users with Prebid Server.
- [Prebid Server Stored Request](#prebid-server-stored-request): This is the Prebid Server Stored Bid Request.
- [AMP content page](#amp-content-page): This is where your content lives.
- [HTML Creative](#html-creative): This is the creative your Ad Ops team puts in your ad server.
- [User Sync in AMP](#user-sync): This is the `amp-iframe` pixel that must be added to your AMP page to sync users with Prebid Server.

### Prebid Server Stored Request

Expand All @@ -54,12 +53,12 @@ You will have to create at least one Stored Request for Prebid Server. Valid St
An example Stored Request is given below. You'll see that the Stored Request contains some important info
that doesn't come from /amp parameters:

* cur
* schain
* ext.prebid.cache.bids - needed to let Prebid Server know that you want it to store the result in PBC
* ext.prebid.targeting.pricegranularity - needed to let Prebid Server know how to calculate the price bucket
* ext.prebid.aliases
* bidders and their parameters
- cur
- schain
- ext.prebid.cache.bids - needed to let Prebid Server know that you want it to store the result in PBC
- ext.prebid.targeting.pricegranularity - needed to let Prebid Server know how to calculate the price bucket
- ext.prebid.aliases
- bidders and their parameters

```json
{
Expand Down Expand Up @@ -129,10 +128,10 @@ This script provides code libraries that will convert `<amp-ad>` properties to t

The `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][PBS], which handles the communication with AMP RTC.
* `vendors` is 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](https://github.com/ampproject/amphtml/blob/master/src/service/real-time-config/callout-vendors.js). We recommend working with your Prebid Server hosting company to set up which bidders and parameters should be involved for each AMP ad unit.
* `timeoutMillis` is 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.
- `data-slot`: Identifies the ad slot for the auction.
- `rtc-config`: Used to pass JSON configuration data to [Prebid Server][PBS], which handles the communication with AMP RTC.
- `vendors` is 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](https://github.com/ampproject/amphtml/blob/master/src/service/real-time-config/callout-vendors.js). We recommend working with your Prebid Server hosting company to set up which bidders and parameters should be involved for each AMP ad unit.
- `timeoutMillis` is 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.

e.g. for the AppNexus cluster of Prebid Servers:

Expand Down Expand Up @@ -222,15 +221,15 @@ Replace `MACRO` in the preceding example with the appropriate macro for the ad s

### User Sync

To sync user IDs with Prebid Server, the `amp-iframe` below may be added to your AMP pages referring to `load-cookie.html` or if you're running an IAB-compliant AMP CMP you can use `load-cookie-with-consent.html`.
To sync user IDs with Prebid Server, the `amp-iframe` below may be added to your AMP pages referring to `load-cookie.html`.

Note that AMP constrains syncing as described in the [amp-iframe](https://amp.dev/documentation/components/amp-iframe) documentation. You may only have *one* amp-iframe on your page that is small, e.g. 1x1. Many publishers already have some kind of analytics or tracking frame on their page, so they may find it difficult to manage this. Several hacks are possible, including building a 'frankenstein' script that combines all of your required tracking into one or tying the sync to an image that's large enough to be visible.
AMP constrains syncing as described in the [amp-iframe](https://amp.dev/documentation/components/amp-iframe) documentation. You may only have *one* amp-iframe on your page that is small, e.g. 1x1. Many publishers already have some kind of analytics or tracking frame on their page, so they may find it difficult to manage this. Several hacks are possible, including building a 'frankenstein' script that combines all of your required tracking into one or tying the sync to an image that's large enough to be visible.

Notes:

* The following examples include a transparent image as a placeholder which will allow you to place the example at the top within the HTML body. If this is not included the iFrame 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](https://amp.dev/documentation/components/amp-iframe/)
* Note that the `sandbox` parameter to the amp-iframe must include both "allow-scripts" and "allow-same-origin".
* The load-cookie-with-consent.html file has the same argument syntax as load-cookie.html. It's a different file because it's larger and depends on the existence of an AMP Consent Management Platform.
- The following examples include a transparent image as a placeholder which will allow you to place the example at the top within the HTML body. If this is not included the iFrame 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](https://amp.dev/documentation/components/amp-iframe/)
- The `sandbox` parameter to the amp-iframe must include both "allow-scripts" and "allow-same-origin".
- If your PBS host company is using a version of `load-cookie.html` older than July of 2024 and if your AMP page is using a CMP, you should consider using `load-cookie-with-consent.html` instead. It's the same functionality, but older versions of `load-cookie.html` cannot read from CMPs.

If you're using AppNexus' managed service, you would enter something like this:

Expand Down Expand Up @@ -268,44 +267,44 @@ Or you can specify a full URL to another Prebid Server location (including a QA
</amp-iframe>
```

See [manually initiating a sync](/prebid-server/developers/pbs-cookie-sync.html#manually-initiating-a-sync) for more information about the available parameters.
See [manually initiating a sync](/prebid-server/developers/pbs-cookie-sync.html#manually-initiating-a-sync) for more information about the available parameters and for how to host the load-cookie script.

### AMP RTC

If you're using a custom RTC callout rather than one of the pre-defined [vendor callouts](https://github.com/ampproject/amphtml/blob/main/src/service/real-time-config/callout-vendors.js), here are the parameters that can be passed through the RTC string:

* tag_id (this correspondes to the Prebid Server stored request ID)
* w=ATTR(width)
* h=ATTR(height)
* ow=ATTR(data-override-width)
* oh=ATTR(data-override-height)
* ms=ATTR(data-multi-size)
* slot=ATTR(data-slot)
* targeting=TGT
* curl=CANONICAL_URL
* timeout=TIMEOUT
* adc=ADCID
* purl=HREF
* gdpr_consent=CONSENT_STRING
* consent_type=CONSENT_METADATA(consentStringType)
* gdpr_applies=CONSENT_METADATA(gdprApplies)
* attl_consent=CONSENT_METADATA(additionalConsent)
- tag_id (this correspondes to the Prebid Server stored request ID)
- w=ATTR(width)
- h=ATTR(height)
- ow=ATTR(data-override-width)
- oh=ATTR(data-override-height)
- ms=ATTR(data-multi-size)
- slot=ATTR(data-slot)
- targeting=TGT
- curl=CANONICAL_URL
- timeout=TIMEOUT
- adc=ADCID
- purl=HREF
- gdpr_consent=CONSENT_STRING
- consent_type=CONSENT_METADATA(consentStringType)
- gdpr_applies=CONSENT_METADATA(gdprApplies)
- attl_consent=CONSENT_METADATA(additionalConsent)

## Debugging Tips

To review that Prebid on AMP is working properly the following aspects can be looked at:

* Include `#development=1` to the URL to review AMP specifc debug messages in the browser console.
* Look for the Prebid server call in the network panel. You can open this URL in a new tab to view additional debugging information relating to the Prebid Server Stored Bid Request. If working properly, Prebid server will display the targeting JSON for AMP to use.
* Look for the network call from the Ad Server to ensure that key values are being passed. (For Google Ad Manager these are in the `scp` query string parameter in the network request)
* Most of the debugging information is omitted from the Prebid Server response unless the `debug=1` parameter is present in the Prebid Server query string. AMP won't add this parameter, so you'll need to grab the Prebid Server URL and manually add it to see the additional information provided.
- Include `#development=1` to the URL to review AMP specifc debug messages in the browser console.
- Look for the Prebid server call in the network panel. You can open this URL in a new tab to view additional debugging information relating to the Prebid Server Stored Bid Request. If working properly, Prebid server will display the targeting JSON for AMP to use.
- Look for the network call from the Ad Server to ensure that key values are being passed. (For Google Ad Manager these are in the `scp` query string parameter in the network request)
- Most of the debugging information is omitted from the Prebid Server response unless the `debug=1` parameter is present in the Prebid Server query string. AMP won't add this parameter, so you'll need to grab the Prebid Server URL and manually add it to see the additional information provided.

## Further Reading

* [Prebid Server and AMP](/prebid-server/use-cases/pbs-amp.html)
* [Google Ad Manager with Prebid Step by Step](/adops/step-by-step.html) (Ad Ops Setup)
* [AMP RTC Overview](https://github.com/ampproject/amphtml/blob/master/extensions/amp-a4a/rtc-documentation.md)
* [callout-vendors.js]
- [Prebid Server and AMP](/prebid-server/use-cases/pbs-amp.html)
- [Google Ad Manager with Prebid Step by Step](/adops/step-by-step.html) (Ad Ops Setup)
- [AMP RTC Overview](https://github.com/ampproject/amphtml/blob/master/extensions/amp-a4a/rtc-documentation.md)
- [callout-vendors.js]

<!-- Reference Links -->

Expand Down
Loading