Skip to content

Commit

Permalink
Prebid.js: new PAAPI module documentation (#5135)
Browse files Browse the repository at this point in the history
* Prebid.js: new PAAPI module documentation

* remove references to reuse

* feedback

* Update paapi.md

* Update paapi.md

* added auctionconfig note

from #5128

---------

Co-authored-by: bretg <bgorsline@gmail.com>
  • Loading branch information
dgirardi and bretg authored Apr 19, 2024
1 parent 88eb230 commit 8bac533
Show file tree
Hide file tree
Showing 4 changed files with 347 additions and 138 deletions.
169 changes: 31 additions & 138 deletions dev-docs/modules/fledgeForGpt.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,172 +2,65 @@
layout: page_v2
page_type: module
title: Module - fledgeForGpt
description: how to use fledge with GPT
description: how to use PAAPI with GPT
module_code : fledgeForGpt
display_name : Fledge for GPT
display_name : Fledge (PAAPI) for GPT
enable_download : true
sidebarType : 1
---

# Fledge (Protected Audience) for GPT Module
# Protected Audience API (PAAPI) for GPT Module

This module allows Prebid.js to support FLEDGE by integrating it with GPT's [experimental FLEDGE
support](https://github.com/google/ads-privacy/tree/master/proposals/fledge-multiple-seller-testing).
This module allows Prebid.js to support PAAPI (formerly FLEDGE) by integrating with GPT's support for [component auctions](https://developers.google.com/publisher-tag/reference#googletag.config.componentauctionconfig).

To learn more about FLEDGE in general, go [here](https://github.com/WICG/turtledove/blob/main/FLEDGE.md).
To learn more about PAAPI in general, go [here](https://github.com/WICG/turtledove/blob/main/FLEDGE.md).

This document covers the steps necessary for publishers to enable FLEDGE on their inventory. It also describes
the changes Bid Adapters need to implement in order to support FLEDGE.
Note that Prebid can't help anyone with which fields to include in auctionconfig, but you can start by looking in [this section](https://github.com/WICG/turtledove/blob/main/FLEDGE.md#21-initiating-an-on-device-auction) of the PAAPI documentation.

## Publisher Integration

Publishers wishing to enable FLEDGE support must do two things. First, they must compile Prebid.js with support for this module.
This is accomplished by adding the `fledgeForGpt` module to the list of modules they are already using:
To use PAAPI with GPT:

```bash
gulp build --modules=fledgeForGpt,...
```

Second, they must enable FLEDGE in their Prebid.js configuration.
This is done through module level configuration, but to provide a high degree of flexiblity for testing, FLEDGE settings also exist at the bidder level and slot level.

### Module Configuration

This module exposes the following settings:
- include this module with your Prebid.js bundle; this also automatically includes the [PAAPI module](/dev-docs/modules/paapi.html)

{: .table .table-bordered .table-striped }
|Name |Type |Description |Notes |
| ------------ | ------------ | ------------ |------------ |
|enabled | Boolean |Enable/disable the module |Defaults to `false` |
|bidders | Array[String] |Optional list of bidders |Defaults to all bidders |
|defaultForSlots | Number |Default value for `imp.ext.ae` in requests for specified bidders |Should be 1 |

As noted above, FLEDGE support is disabled by default. To enable it, set the `enabled` value to `true` for this module and configure `defaultForSlots` to be `1` (meaning _Client-side auction_).
using the `setConfig` method of Prebid.js. Optionally, a list of
bidders to apply these settings to may be provided:

```js
pbjs.que.push(function() {
pbjs.setConfig({
fledgeForGpt: {
enabled: true,
bidders: ['openx', 'rtbhouse'],
defaultForSlots: 1
}
});
});
```
```bash
gulp build --modules=fledgeForGpt,...
```

### Bidder Configuration
- [configure PAAPI](/dev-docs/modules/paapi.html#config)
- (optional) invoke [setPAAPIConfigForGPT](/dev-docs/publisher-api-reference/setPAAPIConfigForGPT.html) at end of auction.

This module adds the following setting for bidders:
By default, Prebid.js attempts to configure GPT slots for PAAPI at the end of each auction. This requires GPT to be loaded before the first Prebid auction is started; to avoid this requirement, or for more control in general over GPT slot configuration, you can use [`setPAAPIConfigForGPT`](/dev-docs/publisher-api-reference/setPAAPIConfigForGPT.html).

{: .table .table-bordered .table-striped }
|Name |Type |Description |Notes |
| ------------ | ------------ | ------------ |------------ |
| fledgeEnabled | Boolean | Enable/disable a bidder to participate in FLEDGE | Defaults to `false` |
|defaultForSlots | Number |Default value for `imp.ext.ae` in requests for specified bidders |Should be 1|
## Explicit configuration

In addition to enabling FLEDGE at the module level, individual bidders must also be enabled. This allows publishers to
selectively test with one or more bidders as they desire. To enable one or more bidders, use the `setBidderConfig` method
of Prebid.js:
First, disable automatic configuration of GPT slots:

```js
pbjs.setBidderConfig({
bidders: ["openx"],
config: {
fledgeEnabled: true,
defaultForSlots: 1
}
});
```

### AdUnit Configuration

All adunits can be opted-in to FLEDGE in the global config via the `defaultForSlots` parameter.
If needed, adunits can be configured individually by setting an attribute of the `ortb2Imp` object for that
adunit. This attribute will take precedence over `defaultForSlots` setting.

{: .table .table-bordered .table-striped }
|Name |Type |Description |Notes |
| ------------ | ------------ | ------------ |------------ |
| ortb2Imp.ext.ae | Integer | Auction Environment: 1 indicates FLEDGE eligible, 0 indicates it is not | Absence indicates this is not FLEDGE eligible |

The `ae` field stands for Auction Environment and was chosen to be consistent with the field that GAM passes to bidders
in their Open Bidding and Exchange Bidding APIs. More details on that can be found
[here](https://github.com/google/ads-privacy/tree/master/proposals/fledge-rtb#bid-request-changes-indicating-interest-group-auction-support)
In practice, this looks as follows:

```js
pbjs.addAdUnits({
code: "my-adunit-div",
// other config here
ortb2Imp: {
ext: {
ae: 1
pbjs.setConfig({
paapi: {
gpt: {
autoconfig: false
}
}
});
})
```

## Bid Adapter Integration

Chrome has enabled a two-tier auction in FLEDGE. This allows multiple sellers (frequently SSPs) to act on behalf of the publisher with
a single entity serving as the final decision maker. In their [current approach](https://github.com/google/ads-privacy/tree/master/proposals/fledge-multiple-seller-testing),
GPT has opted to run the final auction layer while allowing other SSPs/sellers to participate as
[Component Auctions](https://github.com/WICG/turtledove/blob/main/FLEDGE.md#21-initiating-an-on-device-auction) which feed their
bids to the final layer. To learn more about Component Auctions, go [here](https://github.com/WICG/turtledove/blob/main/FLEDGE.md#24-scoring-bids-in-component-auctions).

The FLEDGE auction, including Component Auctions, are configured via an `AuctionConfig` object that defines the parameters of the auction for a given
seller. This module enables FLEDGE support by allowing bid adaptors to return `AuctionConfig` objects in addition to bids. If a bid adaptor returns an
`AuctionConfig` object, Prebid.js will register it with the appropriate GPT ad slot so the bidder can participate as a Component Auction in the overall
FLEDGE auction for that slot. More details on the GPT API can be found [here](https://developers.google.com/publisher-tag/reference#googletag.config.componentauctionconfig).

Modifying a bid adapter to support FLEDGE is a straightforward process and consists of the following steps:

1. Detecting when a bid request is FLEDGE eligible
2. Responding with AuctionConfig

FLEDGE eligibility is made available to bid adapters through the `bidderRequest.fledgeEnabled` field.
The [`bidderRequest`](/dev-docs/bidder-adaptor.html#bidderrequest-parameters) object is passed to
the [`buildRequests`](/dev-docs/bidder-adaptor.html#building-the-request) method of an adapter. Bid adapters
who wish to participate should read this flag and pass it to their server. FLEDGE eligibility depends on a number of parameters:

1. Chrome enablement
2. Publisher participation in the [Origin Trial](https://developer.chrome.com/docs/privacy-sandbox/unified-origin-trial/#configure)
3. Publisher Prebid.js configuration (detailed above)

When a bid request is FLEDGE enabled, a bid adapter can return a tuple consisting of bids and AuctionConfig objects rather than just a list of bids:
You may then use `setPAAPIConfigForGPT`, typically from a `bidsBackHandler`:

```js
function interpretResponse(resp, req) {
// Load the bids from the response - this is adapter specific
const bids = parseBids(resp);

// Load the auctionConfigs from the response - also adapter specific
const fledgeAuctionConfigs = parseAuctionConfigs(resp);

if (fledgeAuctionConfigs) {
// Return a tuple of bids and auctionConfigs. It is possible that bids could be null.
return {bids, fledgeAuctionConfigs};
} else {
return bids;
}
}
pbjs.requestBids({
// ...
bidsBackHandler: function(bids, timedOut, auctionId) {
pbjs.setPAAPIConfigForGPT();
// ...
}
})
```

An AuctionConfig must be associated with an adunit and auction, and this is accomplished using the value in the `bidId` field from the objects in the
`validBidRequests` array passed to the `buildRequests` function - see [here](/dev-docs/bidder-adaptor.html#ad-unit-params-in-the-validbidrequests-array)
for more details. This means that the AuctionConfig objects returned from `interpretResponse` must contain a `bidId` field whose value corresponds to
the request it should be associated with. This may raise the question: why isn't the AuctionConfig object returned as part of the bid? The
answer is that it's possible to participate in the FLEDGE auction without returning a contextual bid.

An example of this can be seen in the OpenX bid adapter [here](https://github.com/prebid/Prebid.js/blob/master/modules/openxBidAdapter.js) or RTB House bid adapter [here](https://github.com/prebid/Prebid.js/blob/master/modules/rtbhouseBidAdapter.js).

Other than the addition of the `bidId` field, the `AuctionConfig` object should adhere to the requirements set forth in FLEDGE. The details of creating an
`AuctionConfig` object are beyond the scope of this document.
See the [API reference](/dev-docs/publisher-api-reference/setPAAPIConfigForGpt.html) for more options.

## Related Reading

- [PAAPI module](/dev-docs/modules/paapi.html)
- [FLEDGE](https://github.com/WICG/turtledove/blob/main/FLEDGE.md)
- [Component Auctions](https://github.com/WICG/turtledove/blob/main/FLEDGE.md#21-initiating-an-on-device-auction)
182 changes: 182 additions & 0 deletions dev-docs/modules/paapi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
---
layout: page_v2
page_type: module
title: Module - PAAPI
description: Protected Audience API
module_code : paapi
display_name : PAAPI
enable_download : true
sidebarType : 1
---

# PAAPI module

This module allows Prebid.js to support PAAPI, formerly known as [FLEDGE](https://github.com/WICG/turtledove/blob/main/FLEDGE.md).

This document covers the steps necessary for publishers to enable PAAPI on their inventory. It also describes
the changes Bid Adapters need to implement in order to support PAAPI.

A related module, [fledgeForGpt](/dev-docs/modules/fledgeForGpt.html), adds support specifically for GPT's [component auctions](https://developers.google.com/publisher-tag/reference#googletag.config.componentauctionconfig).

## Publisher Integration

To use PAAPI, publishers must:

- include this module in their Prebid.js bundle

```bash
gulp build --modules=paapi,...
```

- enable PAAPI, globally or by ad unit, through [configuration](#config)
- manage the PAAPI auctions. This can be delegated to GPT with the [fledgeForGpt module](/dev-docs/modules/fledgeForGpt.html); homegrown solutions are possible with [getPAAPIConfig](/dev-docs/publisher-api-reference/getPAAPIConfig.html), but out of scope for this document.

<a id="config"></a>

### Module Configuration

This module exposes the following settings:

{: .table .table-bordered .table-striped }
|Name |Type |Description |Notes |
| ------------ | ------------ | ------------ |------------ |
|enabled | Boolean |Enable/disable the module |Defaults to `false` |
|bidders | Array[String] |Optional list of bidders |Defaults to all bidders |
|defaultForSlots | Number |Default value for `imp.ext.ae` in requests for specified bidders |Should be 1 |

As noted above, PAAPI support is disabled by default. To enable it, set the `enabled` value to `true` for this module and configure `defaultForSlots` to be `1` (meaning _Client-side auction_).
using the `setConfig` method of Prebid.js:

```js
pbjs.que.push(function() {
pbjs.setConfig({
paapi: {
enabled: true,
defaultForSlots: 1
}
});
});
```

Optionally, PAAPI support can be limited to specific bidders:

```js
pbjs.que.push(function() {
pbjs.setConfig({
paapi: {
enabled: true,
defaultForSlots: 1,
bidders: ['bidderA', 'bidderB']
}
});
});
```

### Bidder Configuration

This module adds the following setting for bidders:

{: .table .table-bordered .table-striped }
|Name |Type |Description |Notes |
| ------------ | ------------ | ------------ |------------ |
| fledgeEnabled | Boolean | Enable/disable a bidder to participate in FLEDGE | Defaults to `false` |
|defaultForSlots | Number |Default value for `imp.ext.ae` in requests for specified bidders |Should be 1|

In addition to enabling PAAPI at the module level, individual bidders can also be enabled. This allows publishers to
selectively test with one or more bidders as they desire. To enable one or more bidders, use the `setBidderConfig` method
of Prebid.js:

```js
pbjs.setBidderConfig({
bidders: ["bidderA"],
config: {
fledgeEnabled: true,
defaultForSlots: 1
}
});
```

### AdUnit Configuration

All adunits can be opted-in to PAAPI in the global config via the `defaultForSlots` parameter.
If needed, adunits can be configured individually by setting an attribute of the `ortb2Imp` object for that
adunit. This attribute will take precedence over `defaultForSlots` setting.

{: .table .table-bordered .table-striped }
|Name |Type |Description |Notes |
| ------------ | ------------ | ------------ |------------ |
| ortb2Imp.ext.ae | Integer | Auction Environment: 1 indicates PAAPI eligible, 0 indicates it is not | Absence indicates this is not PAAPI eligible |

The `ae` field stands for Auction Environment and was chosen to be consistent with the field that GAM passes to bidders
in their Open Bidding and Exchange Bidding APIs. More details on that can be found
[here](https://github.com/google/ads-privacy/tree/master/proposals/fledge-rtb#bid-request-changes-indicating-interest-group-auction-support)
In practice, this looks as follows:

```js
pbjs.addAdUnits({
code: "my-adunit-div",
// other config here
ortb2Imp: {
ext: {
ae: 1
}
}
});
```

## Bid Adapter Integration

Chrome has enabled a two-tier auction in PAAPI. This allows multiple sellers (frequently SSPs) to act on behalf of the publisher with
a single entity serving as the final decision maker. In their [current approach](https://github.com/google/ads-privacy/tree/master/proposals/fledge-multiple-seller-testing),
GPT has opted to run the final auction layer while allowing other SSPs/sellers to participate as
[Component Auctions](https://github.com/WICG/turtledove/blob/main/FLEDGE.md#21-initiating-an-on-device-auction) which feed their
bids to the final layer. To learn more about Component Auctions, go [here](https://github.com/WICG/turtledove/blob/main/FLEDGE.md#24-scoring-bids-in-component-auctions).

The PAAPI auction, including Component Auctions, are configured via an `AuctionConfig` object that defines the parameters of the auction for a given
seller. This module enables PAAPI support by allowing bid adaptors to return `AuctionConfig` objects in addition to bids. If a bid adaptor returns an
`AuctionConfig` object, Prebid.js will make it available through [`getPAAPIConfig`](/dev-docs/publisher-api-reference/getPAAPIConfig.html), as well as other PAAPI modules such as [fledgeForGpt](/dev-docs/modules/fledgeForGpt.html).

Modifying a bid adapter to support PAAPI is a straightforward process and consists of the following steps:

1. Detecting when a bid request is PAAPI eligible
2. Responding with AuctionConfig

PAAPI eligibility is made available to bid adapters' [`buildRequests`](/dev-docs/bidder-adaptor.html#building-the-request) method through the `ortb2Imp.ext.ae` property of bid requests; it is set to `1` when the browser supports PAAPI and publisher configuration has enabled it as described above. Bid adapters
who wish to participate should read this flag and pass it to their server.
When a bid request is PAAPI enabled, a bid adapter can return a tuple consisting of bids and AuctionConfig objects rather than just a list of bids:
```js
function interpretResponse(resp, req) {
// Load the bids from the response - this is adapter specific
const bids = parseBids(resp);
// Load the auctionConfigs from the response - also adapter specific
const fledgeAuctionConfigs = parseAuctionConfigs(resp);
if (fledgeAuctionConfigs) {
// Return a tuple of bids and auctionConfigs. It is possible that bids could be null.
return {bids, fledgeAuctionConfigs};
} else {
return bids;
}
}
```
An AuctionConfig must be associated with an adunit and auction, and this is accomplished using the value in the `bidId` field from the objects in the
`validBidRequests` array passed to the `buildRequests` function - see [here](/dev-docs/bidder-adaptor.html#ad-unit-params-in-the-validbidrequests-array)
for more details. This means that the AuctionConfig objects returned from `interpretResponse` must contain a `bidId` field whose value corresponds to
the request it should be associated with. This may raise the question: why isn't the AuctionConfig object returned as part of the bid? The
answer is that it's possible to participate in the PAAPI auction without returning a contextual bid.
An example of this can be seen in the OpenX bid adapter [here](https://github.com/prebid/Prebid.js/blob/master/modules/openxBidAdapter.js) or RTB House bid adapter [here](https://github.com/prebid/Prebid.js/blob/master/modules/rtbhouseBidAdapter.js).
Other than the addition of the `bidId` field, the `AuctionConfig` object should adhere to the requirements set forth in PAAPI. The details of creating an
`AuctionConfig` object are beyond the scope of this document.
## Related Reading
- [fledgeForGpt module](/dev-docs/modules/fledgeForGpt.html)
- [Protected Audience API (PAAPI)](https://github.com/WICG/turtledove/blob/main/FLEDGE.md), formerly FLEDGE
- [Component Auctions](https://github.com/WICG/turtledove/blob/main/FLEDGE.md#21-initiating-an-on-device-auction)
- [getPAAPIConfig](/dev-docs/publisher-api-reference/getPAAPIConfig.html)
Loading

0 comments on commit 8bac533

Please sign in to comment.