广告投放受限和第一方标识符设置

借助受限广告,即使您的用户不同意分享个人数据,应用也能投放广告。 受限广告模式会停止出于广告选择的目的收集、共享和使用个人数据。如果用户选择不分享个人数据,此功能可让广告继续投放。

本指南介绍了如何在应用中使用受限广告设置,以及如何使应用行为与 Google Ad Manager 广告资源网的全局设置保持一致。

配置客户端受限广告设置

PAL 版本 1.109.0 引入了 forceLimitedAds 属性,并移除了 allowStorage 属性。此属性位于 ConsentSettings 类中。

从版本 1.109.0 开始,PAL 会从设备读取透明度和用户意见征求框架 (TCF) 数据,以确定用户是否同意访问本地存储数据。以前,您的应用负责确定存储权限同意情况。您的应用仍必须在广告代码网址中传递 gdpr= 和 gdpr_consent= 参数。

如果基于 TCF 的自动确定不足以满足需求,请直接在应用中设置 forceLimitedAds 属性。如需了解详情,请参阅发布商集成 IAB Europe TCF。 将 forceLimitedAds 属性设置为 true 值可防止 PAL 在发送到服务器的随机数中存储或发送用户标识符。将 forceLimitedAds 属性设置为 true 值与在 IMA(互动式媒体广告)SDK 中向广告请求网址添加 ltd=1 参数的效果相同。如需详细了解受限广告,请参阅ltd(受限广告)。 当您将 forceLimitedAds 属性设置为 true 值时,PAL 会在 Nonce 中包含 ltd=1 参数。

为了在应用中保留当前运作机制,您可能需要更新实现方式;即使您之前没有设置过 allowStorage 属性,也需要更新。allowStorage 属性默认设置为 false 值,这会启用受限广告。forceLimitedAds 属性的默认值为 false,不会启用受限广告。

与 Google Ad Manager 全局设置保持一致

如果您更新了 Ad Manager 设置程序化受限广告或允许将第一方 Cookie 用于在网站中展示的广告,请使用这些新 API 来匹配 Ad Manager 中的设置。如果您不使用这些 API,PAL 可能会在广告请求中使用的随机数中包含标识符。不过,Ad Manager 可能会根据 Ad Manager 中的设置舍弃信号。

这些 API 如下所示:

  • disableLimitedAdsStorage - 停用仅用于检测无效流量的 Cookie,并禁止使用本地存储来投放受限广告。如果您在 Ad Manager 中的管理 > 全局设置中更新了程序化受限广告设置,请使用此 API 停用 PAL 中受限广告的本地存储空间使用情况。请注意,此设置不适用于非受限广告。
  • disableFirstPartyIdentifiers - 停用用于选择广告的第一方标识符。如果您在 Ad Manager 的管理 > 全局设置中更新了允许将第一方 Cookie 用于在网站中展示的广告设置,请使用此 API 在 PAL 中停用此类标识符。请注意,此设置不适用于使用 Cookie 和本地存储空间来检测无效流量。

以下示例展示了如何在 PAL 实现中处理用户隐私权和数据使用情况:

const consentSettings = new goog.pal.ConsentSettings();
consentSettings.allowStorage = true;
// During the PAL Phase 1 release, best practice is to always set the
// `allowStorage` property to a `true` value to allow PAL to automatically
// determine whether limited ads applies based on the TCF data.
// To enable limited ads regardless of the TCF determination, set the
// `forceLimitedAds` property to a `true` value.

const adManagerSettings = new goog.pal.GoogleAdManagerSettings();
// Add this line if the "Programmatic limited ads" toggle is turned off in
// Ad Manager.
adManagerSettings.disableLimitedAdsStorage = true;
// Add this line if the "First party cookies for ads on web" toggle
// is turned off in Ad Manager.
adManagerSettings.disableFirstPartyIdentifiers = true;

const nonceLoader = new goog.pal.NonceLoader(consentSettings, adManagerSettings);