廣告和第一方 ID 設定受限

如果您更新 Ad Manager 設定「程式輔助受限制的廣告」或「應用程式廣告的第一方 ID」,請使用這些新 API 與 Ad Manager 中的設定相符。如果您未使用 API,PAL 可能會在用於向伺服器傳送廣告要求的 Nonce 中加入 ID。不過,Ad Manager 可能會根據 Ad Manager 中的設定捨棄信號。

這些 API 如下:

  • disableLimitedAdsStorage - 停用偵測無效流量專用的 ID,並停用受限制廣告的本機儲存空間。如果您在 Ad Manager 中更新了「管理」>「全域設定」中的程式輔助受限制的廣告設定,請使用這個 API 停用 PAL 中受限制廣告的本機儲存空間用途。請注意,這項設定不適用於未受限的廣告。
  • disableFirstPartyIdentifiers:停用用於廣告選擇的第一方 ID。如果您在 Ad Manager 中更新了「管理」>「通用」設定中的應用程式廣告第一方 ID設定,請使用這個 API 在 PAL 中停用這類 ID。請注意,這項設定不適用於使用 ID 和本機儲存空間偵測無效流量。

以下範例會設定這些參數:

ConsentSettings consentSettings = ConsentSettings.builder()
            .allowStorage(isConsentToStorage)
            .build();

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);