From 72c90afe482e46160d728b28efe050e26432023a Mon Sep 17 00:00:00 2001 From: kevinkiklee Date: Mon, 4 Dec 2023 09:50:22 -0500 Subject: [PATCH] Update FF ads reporting API example --- .../protected-audience-api/reporting/index.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/site/en/docs/privacy-sandbox/protected-audience-api/reporting/index.md b/site/en/docs/privacy-sandbox/protected-audience-api/reporting/index.md index 923dd4bc160e..0b33802fc42c 100644 --- a/site/en/docs/privacy-sandbox/protected-audience-api/reporting/index.md +++ b/site/en/docs/privacy-sandbox/protected-audience-api/reporting/index.md @@ -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 [registerAdBeacon()](https://github.com/WICG/turtledove/blob/main/Fenced_Frames_Ads_Reporting.md#registeradbeacon) function and set your signals as query params. Then you trigger the event from a fenced frame by calling the [window.fence.reportEvent()](https://github.com/WICG/turtledove/blob/main/Fenced_Frames_Ads_Reporting.md#reportevent) function with the user event-level data payload. +In Protected Audience API reporting worklets (`reportResult()` and `reportWin()`), you register an ad beacon with the [registerAdBeacon()](https://github.com/WICG/turtledove/blob/main/Fenced_Frames_Ads_Reporting.md#registeradbeacon) function and set your signals as query params. Then you trigger the event from a fenced frame by calling the [window.fence.reportEvent()](https://github.com/WICG/turtledove/blob/main/Fenced_Frames_Ads_Reporting.md#reportevent) 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) { + const { topLevelSeller } = browserSignals; + + // ... + registerAdBeacon({ - click: `https://your-server.example/report/click?campaignId=${campaignId}` - }) + click: `https://your-server.example/report/click?topLevelSeller=${topLevelSeller}` + }); + + return signalsForWinner; } ```