diff --git a/dev-docs/show-prebid-ads-on-amp-pages.md b/dev-docs/show-prebid-ads-on-amp-pages.md index 555b42648b..b9244d2611 100644 --- a/dev-docs/show-prebid-ads-on-amp-pages.md +++ b/dev-docs/show-prebid-ads-on-amp-pages.md @@ -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. @@ -15,11 +14,11 @@ 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). @@ -27,25 +26,25 @@ For ad ops setup instructions, see [Google Ad Manager with Prebid Step by Step]( {% 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 @@ -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 { @@ -129,10 +128,10 @@ This script provides code libraries that will convert `` 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: @@ -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: @@ -268,44 +267,44 @@ Or you can specify a full URL to another Prebid Server location (including a QA ``` -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] diff --git a/prebid-server/developers/pbs-cookie-sync.md b/prebid-server/developers/pbs-cookie-sync.md index 96bcb5e483..fa178b4be4 100644 --- a/prebid-server/developers/pbs-cookie-sync.md +++ b/prebid-server/developers/pbs-cookie-sync.md @@ -33,73 +33,116 @@ Here's how these IDs get placed in the cookie from Prebid.js: ![Prebid Server Cookie Sync](/assets/images/prebid-server/pbs-cookie-sync.png){:class="pb-lg-img"} -1. Prebid.js starts by calling the Prebid Server [`/cookie_sync`](/prebid-server/endpoints/pbs-endpoint-cookieSync.html), letting it know which server-side bidders will be participating in the header bidding auction. +1. When the [s2sConfig](/dev-docs/modules/prebidServer.html) is set, Prebid.js initiates a call to the Prebid Server [`/cookie_sync`](/prebid-server/endpoints/pbs-endpoint-cookieSync.html), letting it know which server-side bidders will be participating in the header bidding auction. - ```text +```text POST https://prebid-server.example.com/cookie_sync {"bidders":["bidderA","bidderB"], "gdpr":1, "gdpr_consent":"...", "us_privacy": "..."} - ``` +``` +{:start="2"} 2. If privacy regulations allow, Prebid Server will look at the `uids` cookie in the host domain and determine whether any bidders are missing or need to be refreshed. It responds with an array of pixel syncs. e.g. - ```javascript +```javascript {"status":"ok","bidder_status":[{"bidder":"bidderA","no_cookie":true,"usersync":{"url":"//biddera.com/getuid?https%3A%2F%2Fprebid-server.example.com%2Fsetuid%3Fbidder%3DbidderA%26gdpr%3D%26gdpr_consent%3D%26us_privacy%3D%26uid%3D%24UID","type":"redirect","supportCORS":false}},{"bidder":"bidderB","no_cookie":true,"usersync":{"url":"https://bidderB.com/u/match?gdpr=&euconsent=&us_privacy=&redir=https%3A%2F%2Fprebid-server.example.com%2Fsetuid%3Fbidder%3DbidderB%26gdpr%3D%26gdpr_consent%3D%26us_privacy%3D%26uid%3D","type":"redirect","supportCORS":false}}]} - ``` +``` -3. When it receives the response, Prebid.js loops through each element of `bidder_status[]`, dropping a pixel for each `bidder_status[].usersync.url`. +{:start="3"} +3. When it receives the response, Prebid.js loops through each element of `bidder_status[]`, creating a pixel for each `bidder_status[].usersync.url`. +{:start="4"} 4. The bidder-specific endpoints read the users' cookie for the bidder's domain and respond with a redirect back to Prebid Server's [`/setuid` endpoint](/prebid-server/endpoints/pbs-endpoint-setuid.html) . This allows that endpoint to read the 3rd party cookie and reflect it back to Prebid Server. Note that if this user doesn't yet have an ID in that 3rd party domain, the sync endpoint is expected to create one. +{:start="5"} 5. When the browser receives this redirect, it contacts Prebid Server, which will once again check the privacy settings and if allowed, update the `uids` cookie. -### Setting the uids cookie from AMP +### Cooperative Syncing + +Prebid Server supports a 'Cooperative Syncing' mode where all enabled bidders may be returned in a sync request even if they aren't on this particular page. This allows bidders to get their IDs in place for the next page where they are utilized. + +Cooperative sync defaults can be configured at the host and account level. See the docs for [PBS-Java](https://github.com/prebid/prebid-server-java/blob/master/docs/config-app.md) and [PBS-Go](https://github.com/prebid/prebid-server/blob/master/config/usersync.go). + +This is how to control the coop syncing behavior from Prebid.js: + +```javascript + pbjs.setConfig({ + s2sConfig: { + ... + coopSync: true, + userSyncLimit: 5 + ... + } + }); +``` + +### Manually initiating a sync -Cookie sync for AMP works in a way quite similar to Prebid.js. +Where Prebid.js isn't present, like on [AMP](/prebid-server/use-cases/pbs-amp.html) pages, the call to [/cookie_sync](/endpoints/pbs-endpoint-cookieSync.html) doesn't happen automatically. +If there are scenarios where Prebid.js isn't around to initiate the /cookie_sync call, publishers can choose to put an iframe on their page. + +This approach works in a way quite similar to Prebid.js except that the [/cookie_sync endpoint](/endpoints/pbs-endpoint-cookieSync.html) is initiated by a separate script that's part of `load-cookie.html'. This file must be placed on a CDN by the publisher's Prebid Server host company. Up until July 2024, the script existed in the [Prebid Universal Creative](https://github.com/prebid/prebid-universal-creative) repository, but has since been moved to the [user-sync](https://github.com/prebid/user-sync) repo. -1. The Prebid Server hosting company places the [load-cookie.html](#manually-initiating-a-sync) file onto a CDN. This script is part of the [Prebid Universal Creative](https://github.com/prebid/prebid-universal-creative/blob/master/src/cookieSync.js) repo. +1. The Prebid Server hosting company places the [load-cookie.html](#manually-initiating-a-sync) file onto a CDN. See [the AMP implementation guide](/dev-docs/show-prebid-ads-on-amp-pages.html#user-sync) for more information. -2. The publisher places the 'load-cookie' iframe into the page: +2. The publisher places a 'load-cookie' iframe into the page: - ```html +For AMP pages: + +```html + src="https://HOST/load-cookie.html?source=amp&endpoint=PBSHOST&max_sync_count=5"> - ``` +``` - {: .alert.alert-info :} - If the publisher has an AMP Consent Management Platform, they should use `load-cookie-with-consent.html`. +On regular web pages: -3. At runtime, the `load-cookie` script just calls the Prebid Server /cookie_sync endpoint. The rest works similar to what's described for Prebid.js above. One difference is that the bidders are not known on the AMP page so those aren't passed. Another difference is that AMP doesn't support iframe syncs, so load-cookie passes instructions to PBS so only pixel syncs are returned. +```html +