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

受限广告让应用 可以在用户不同意共享个人数据的情况下投放广告。 受限广告模式会停止出于广告选择目的而收集、共享和使用个人数据。如果用户选择不共享个人数据,此功能可让广告继续投放。

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

配置客户端受限广告设置

PAL 3.0.0 版引入了 forceLimitedAds 属性,并移除了 allowStorage 属性。此属性位于 PALSettings 类中。

从 3.0.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 值,这 不会启用 受限广告。

更新 PAL 实现以基于 TCF 进行确定

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

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

如果您更新了 Ad Manager 设置程序化受限广告应用内广告的第一方标识符, 请使用这些新 API 使其与 Ad Manager 中的设置保持一致。如果您不使用这些 API,PAL 可能会在广告请求中使用的 Nonce 中添加标识符。不过,Ad Manager 可能会根据 Ad Manager 中的设置舍弃这些信号。

这些 API 如下所示:

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

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

Objective-C

PALSettings *settings = [[PALSettings alloc] init];
// PAL tvOS version 3.0.0 introduces
// `PALSettings.forceLimitedAds` and removes `PALSettings.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.

settings.directedForChildOrUnknownAge = NO;

PALGoogleAdManagerSettings *adManagerSettings = [[PALGoogleAdManagerSettings alloc] init];
// Add this line if the "Programmatic limited ads" toggle is turned off in
// Ad Manager.
adManagerSettings.disableLimitedAdsStorage = YES;
// Add this line if the "First party identifiers for ads on app" toggle
// is turned off in Ad Manager.
adManagerSettings.disableFirstPartyIdentifiers = YES;

self.nonceLoader = [[PALNonceLoader alloc] initWithSettings:settings
                                    googleAdManagerSettings:adManagerSettings];

Swift

let settings = PALSettings()
// PAL tvOS version 3.0.0 introduces
// `PALSettings.forceLimitedAds` and removes `PALSettings.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.

settings.directedForChildOrUnknownAge = false

let adManagerSettings = PALGoogleAdManagerSettings()
// 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 identifiers for ads on app" toggle
// is turned off in Ad Manager.
adManagerSettings.disableFirstPartyIdentifiers = true

self.nonceLoader = PALNonceLoader(
    settings: settings,
    googleAdManagerSettings: adManagerSettings
)