在 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
  //...
}