Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Update FF ads reporting API example #7906

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,22 @@ The `sendReportTo()` function described above can be used to associate auction d

The [Ads Reporting API](https://github.com/WICG/turtledove/blob/main/Fenced_Frames_Ads_Reporting.md) for fenced frames and iframes provides a mechanism for you to associate user event-level data from an ad frame with signals within a Protected Audience auction.

In a Protected Audience API reporting worklet, you register an ad beacon with the <code>[registerAdBeacon()](https://github.com/WICG/turtledove/blob/main/Fenced_Frames_Ads_Reporting.md#registeradbeacon)</code> function and set your signals as query params. Then you trigger the event from a fenced frame by calling the <code>[window.fence.reportEvent()](https://github.com/WICG/turtledove/blob/main/Fenced_Frames_Ads_Reporting.md#reportevent)</code> function with the user event-level data payload.
In Protected Audience API reporting worklets (`reportResult()` and `reportWin()`), you register an ad beacon with the <code>[registerAdBeacon()](https://github.com/WICG/turtledove/blob/main/Fenced_Frames_Ads_Reporting.md#registeradbeacon)</code> function and set your signals as query params. Then you trigger the event from a fenced frame by calling the <code>[window.fence.reportEvent()](https://github.com/WICG/turtledove/blob/main/Fenced_Frames_Ads_Reporting.md#reportevent)</code> function with the user event-level data payload.

In the following example, a campaign ID is associated with an event-level payload that the click coordinates:

```js
// Protected Audience API worklet
function generateBid(interestGroup) {
const { campaignId } = interestGroup.ads.metadata;
// Protected Audience API reporting worklet
function reportResult(auctionConfig, browserSignals, directFromSellerSignals) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably better to use a buyer example as there's likely more buyers than sellers

Suggested change
function reportResult(auctionConfig, browserSignals, directFromSellerSignals) {
function reportWin(auctionSignals, perBuyerSignals, sellerSignals, browserSignals, directFromSellerSignals) {

const { topLevelSeller } = browserSignals;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's simplify a bit

Suggested change
const { topLevelSeller } = browserSignals;


// ...

registerAdBeacon({
click: `https://your-server.example/report/click?campaignId=${campaignId}`
})
click: `https://your-server.example/report/click?topLevelSeller=${topLevelSeller}`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
click: `https://your-server.example/report/click?topLevelSeller=${topLevelSeller}`
click: `https://your-server.example/report/click?seller=${browserSignals.seller}`

});

return signalsForWinner;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simplifies a bit if we're reportWin

Suggested change
return signalsForWinner;

}
```

Expand Down
Loading