廣告和第一方 ID 設定受限
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如果您更新 Ad Manager 設定「程式輔助受限制的廣告」或「用於網站廣告的第一方 Cookie」,請使用這些新 API 與 Ad Manager 中的設定相符。如果您未使用 API,PAL 可能會在用於向伺服器傳送廣告要求的 Nonce 中加入 ID。不過,Ad Manager 可能會根據 Ad Manager 中的設定捨棄信號。
這些 API 如下:
disableLimitedAdsStorage
- 停用偵測無效流量專用的 Cookie,並停用受限制廣告的本機儲存空間。如果您在 Ad Manager 中更新了「管理」>「全域設定」中的「程式輔助受限制的廣告」設定,請使用這個 API 停用 PAL 中受限制廣告的本機儲存空間用途。請注意,這項設定不適用於未受限的廣告。
disableFirstPartyIdentifiers
:停用用於廣告選擇的第一方 ID。如果您在 Ad Manager 中更新了「管理」>「全域」設定中的「網站廣告的第一方 Cookie」設定,請使用這個 API 在 PAL 中停用這類 ID。請注意,這項設定不適用於偵測無效流量時使用 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);
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-21 (世界標準時間)。
[null,null,["上次更新時間: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);"]]