广告投放受限和第一方标识符设置
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如果您更新了 Ad Manager 设置“程序化广告受限”或“适用于网站广告的第一方 Cookie”,请使用这些新 API 来匹配 Ad Manager 中的设置。如果您不使用这些 API,PAL 可能会在向服务器发送的广告请求中使用的 Nonce 中包含标识符。不过,Ad Manager 可能会根据 Ad Manager 中的设置舍弃这些信号。
这些 API 如下所示:
disableLimitedAdsStorage
- 停用仅用于检测无效流量的 Cookie,并禁止为受限广告使用本地存储。如果您在 Ad Manager 的管理 > 全局设置中更新了程序化受限广告设置,请使用此 API 在 PAL 中停用对受限广告使用本地存储空间。请注意,此设置不适用于无限制广告。
disableFirstPartyIdentifiers
- 停用用于广告选择的第一方标识符。如果您在 Ad Manager 的管理 > 全局设置中更新了适用于网站上的广告的第一方 Cookie 设置,请使用此 API 在 PAL 中停用此类标识符。请注意,此设置不适用于将 Cookie 和本地存储用于检测无效流量的情况。
以下示例设置了这些参数:
const consentSettings = new goog.pal.ConsentSettings();
consentSettings.allowStorage = getConsentToStorage();
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);
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-21。
[null,null,["最后更新时间 (UTC):2025-08-21。"],[],[],null,["# Limited ads and first party identifier settings\n\nIf you update the Ad Manager settings **Programmatic limited ads** or\n**First party\ncookies\nfor ads on\nweb**,\nuse these new APIs to match the settings in Ad Manager. If you don't use the\nAPIs PAL might include the identifiers in the nonce that is used in the ad\nrequest to the server. However, Ad Manager might drop the signals based on the\nsettings in Ad Manager.\n\nThe APIs are as follows:\n\n- [`disableLimitedAdsStorage`](/ad-manager/pal/html5/reference/js/GoogleAdManagerSettings#disableLimitedAdsStorage) - disables invalid traffic detection-only cookies and use of local storage for limited ads. If you updated the **Programmatic limited ads** setting in Ad Manager within **Admin \\\u003e Global settings**, use this API to disable usage of local storage for limited ads in PAL. Note that this setting does not apply to non-limited ads.\n- [`disableFirstPartyIdentifiers`](/ad-manager/pal/html5/reference/js/GoogleAdManagerSettings#disableFirstPartyIdentifiers) - disables first-party identifiers used for ad selection. If you updated the **First party\n cookies\n for ads on\n web** setting in Ad Manager within **Admin \\\u003e Global** settings, use this API to disable such identifiers in PAL. Note that this setting does not apply to the use of cookies and local storage for invalid traffic detection.\n\nThe following example sets these parameters: \n\n const consentSettings = new goog.pal.ConsentSettings();\n consentSettings.allowStorage = getConsentToStorage();\n\n const adManagerSettings = new goog.pal.GoogleAdManagerSettings();\n // Add this line if the \"Programmatic limited ads\" toggle is turned off in\n // Ad Manager.\n adManagerSettings.disableLimitedAdsStorage = true;\n // Add this line if the \"First party cookies for ads on web\" toggle\n // is turned off in Ad Manager.\n adManagerSettings.disableFirstPartyIdentifiers = true;\n\n const nonceLoader = new goog.pal.NonceLoader(consentSettings, adManagerSettings);"]]