在 Protected Audience 中将 Topics 与程序化出价结合使用

了解如何将 Topics 中的兴趣作为 Protected Audience 出价和竞价流程的输入内容。Protected Audience 会在多个时间点让买方和卖方将第一方信号传递到出价和竞价流程中。Topics 提供的信号可用于利用有关当前用户兴趣的信息来丰富出价和广告选择流程中可用的数据,从而提高广告资源的潜在价值。

在阅读本指南之前,请确保您熟悉 TopicsProtected Audience

获取主题

调用 Topics API 时,调用方会看到之前针对该浏览器观察到的一组主题。

const currentTopics = await document.browsingTopics();
// Example result
[
 
{
   
"configVersion": "chrome.2",
   
"modelVersion": "4",
   
"taxonomyVersion": "2",
   
"topic": 310,
   
"version": "chrome.2:2:4"
 
}
]

在本例中,主题为:310 映射到“体育/自行车”。

这些示例展示了直接使用的主题值,但完整实现可能会选择处理这些值或将其与其他数据组合。

使用主题有条件地定义兴趣群体

生成的主题可以直接用于选择将用户添加到兴趣群体。

if (currentTopics[0].topic === 310) { // Interest in "Sports/Cycling"
 
const interestGroup = {
  owner
: 'https://dsp.example',
  name
: 'custom-bikes',
 
}
}

向兴趣群体提供买方主题

创建兴趣群体时,当前主题(或通过主题处理的数据)可包含在 userBiddingSignals 中。这样,买方就可以在设置出价时使用主题

const interestGroup = {
  owner
: 'https://dsp.example',
  name
: 'custom-bikes',
  userBiddingSignals
: {
    topics
: currentTopics,
   
....
 
},
 
...
};

navigator
.joinAdInterestGroup(interestGroup, 7 * kSecsPerDay);

为竞价提供卖方主题

在配置竞价时,当前向卖方显示的主题(或通过这些主题处理的数据)可能会以组合形式包含在 auctionSignalssellerSignalsperBuyerSignals 中。这样一来,买方可以在出价时使用主题,卖方可以在为出价评分时使用主题

const myAuctionConfig = {
  seller
: 'https://ssp.example',
  auctionSignals
: {
    topics
: currentTopics,
 
},
  sellerSignals
: {
    topics
: currentTopics,
 
},
  perBuyerSignals
: {
   
'https://dsp.example': {
      topics
: currentTopics,
     
// ...
   
},
   
// ...
 
},
 
// ...
};
const result = await navigator.runAdAuction(myAuctionConfig);

在设置出价时使用主题

然后,在调用买方的 generateBid() 函数后,系统便可使用传入的记录的主题(就像信号中提供的任何其他数据一样)来协助出价。例如,出价方可能会使用“运动/骑车”针对这个 custom-bikes 兴趣群体提高出价。

generateBid(interestGroup, auctionSignals, perBuyerSignals,
    trustedBiddingSignals
, browserSignals) {
 
const topics = interestGroup.userBiddingSignals.topics;
 
// Use the topic values in the bidding logic.
}

对出价进行评分时使用主题

在出价后,在调用卖方的 scoreAd() 函数后,可以像使用从竞价配置传入的任何其他数据一样使用记录的主题。例如,卖方可能希望为与检测到的主题匹配的广告设置更高的出价权重。

scoreAd(adMetadata, bid, auctionConfig, trustedScoringSignals, browserSignals, directFromSellerSignals) {
 
const sellerTopics = actionConfig.auctionSignals.topics;
 
// or corresponding key in sellerSignals
 
// use the topics values to score the ads
 
//...
}