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

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

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

配置客户端受限广告设置

PAL 正在更新其处理设置的方式,以更好地控制用户隐私和数据使用情况。PAL 版本 23.0.0 引入了 forceLimitedAds 属性,并移除了现有的 allowStorage 属性。这些属性位于 ConsentSettings 类中。

从版本 23.0.0 开始,PAL 会从设备读取透明度和用户意见征求框架 (TCF) 数据,以确定用户是否同意访问本地存储数据。对读取 TCF 数据的这一更改使得现有的 allowStorage 属性变得多余。您的应用仍必须在广告代码网址中传递 gdpr=gdpr_consent= 参数。

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

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

更新了 PAL 实现,以基于 TCF 进行判定

在更新到 23.0.0 版本时,PAL Android 需要执行操作,以便 PAL 从设备读取 TCF 数据,以确定用户是否同意访问本地存储数据。此版本还添加了 forceLimitedAds 属性,并移除了 allowStorage 属性。仅当基于 TCF 激活受限广告无法满足应用的要求时,才更新应用以使用 forceLimitedAds 属性。如需详细了解基于 TCF 的确定,请参阅发布商集成 IAB Europe TCF

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

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

这些 API 如下所示:

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

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

ConsentSettings consentSettings = ConsentSettings.builder()
            .directedForChildOrUnknownAge(false)
            .build();
// PAL Android version 23.0.0 introduces
// `ConsentSettings.forceLimitedAds` and removes `ConsentSettings.allowStorage`.
// Best practice is to not set `forceLimitedAds` 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.

GoogleAdManagerSettings adManagerSettings = GoogleAdManagerSettings.builder()
            // Add this line if the "Programmatic limited ads" toggle is turned
            // off in Ad Manager.
            .disableLimitedAdsStorage(true)
            // Add this line if the
            // "First party identifiers for ads on app" toggle is turned
            // off in Ad Manager.
            .disableFirstPartyIdentifiers(true)
            .build();

nonceLoader = new NonceLoader(this, consentSettings, adManagerSettings);