指定目標

本指南說明如何為廣告請求提供指定目標資訊。換 可實際使用的範例應用程式 請下載 Android API 試用版應用程式

下載 API 示範影片

修課條件

RequestConfiguration

RequestConfiguration敬上 物件會收集指定目標資訊,以便全面套用到 a MobileAds 靜態方法。

如要更新要求設定,請從現有的 執行任何需要的更新,並依照下列方式設定:

Java

RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration()
    .toBuilder()
    .build();
MobileAds.setRequestConfiguration(requestConfiguration);

Kotlin

var requestConfiguration = MobileAds.getRequestConfiguration()
  .toBuilder()
  .build()
MobileAds.setRequestConfiguration(requestConfiguration)

兒童導向設定

用於《兒童網路隱私保護法》 (COPPA), 有一項設定是「標記為兒童導向內容」設定。 設定這個代碼,即表示您確認這項通知正確無誤 ,且您是應用程式擁有者的授權代理人。 您瞭解濫用這項設定可能導致帳戶遭到終止 電子郵件地址。

如果您是應用程式開發人員,則可指明是否希望 Google 將 內容標示為兒童導向內容。如果指定 希望 Google 將您的內容視為兒童導向內容,我們會採取相應措施 針對該廣告請求停用按照興趣顯示的廣告和再行銷廣告。

這項設定適用於所有版本的 Google Play 服務 SDK 透過 RequestConfiguration.Builder.setTagForChildDirectedTreatment(int)

  • 透過以下方式致電setTagForChildDirectedTreatmentTAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE 表示您想要 內容視為兒童導向內容。這麼做可以避免 Android 廣告識別碼傳送過程 (AAID)

  • 透過以下方式致電setTagForChildDirectedTreatmentTAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE。 內容視為兒童導向內容。

  • 透過以下方式致電setTagForChildDirectedTreatmentTAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED 我們如何處理廣告請求中的 COPPA 規範

以下範例表示您希望內容 以 COPPA 規範為兒童導向內容:

Java

RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration()
    .toBuilder()
    .setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)
    .build();
MobileAds.setRequestConfiguration(requestConfiguration);

Kotlin

var requestConfiguration = MobileAds.getRequestConfiguration()
  .toBuilder()
  .setTagForChildDirectedTreatment(RequestConfiguration.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)
  .build()
MobileAds.setRequestConfiguration(requestConfiguration)

您可以在 未滿規定年齡的歐洲經濟區 (EEA)。這項功能 協助您遵循《一般大眾內容》 資料保護規則 (GDPR)。請注意,您有其他法律規範 所負責任 AI 技術的義務。詳閱歐盟指南,並向 建議諮詢法律顧問請注意,Google 工具旨在 合乎規定,而非讓任何特定發布商履行其義務 法律。 進一步瞭解 GDPR 對發布商的影響

使用這項功能時,會加上未滿法定同意年齡使用者的代碼 (TFUA) 參數此參數會停用 個人化廣告 (包括再行銷) 功能。此外, 停止向第三方廣告供應商 (例如廣告評估像素和 第三方廣告伺服器

如同兒童導向設定 RequestConfiguration.Builder 用於設定 TFUA 參數: setTagForUnderAgeOfConsent(), 包含下列選項

  • 透過 TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE 撥打 setTagForUnderAgeOfConsent() 代表您希望廣告請求針對 未滿規定年齡的歐洲經濟區 (EEA)。這也 防止傳輸 Android 廣告 ID (AAID)

  • 透過 TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE 撥打 setTagForUnderAgeOfConsent() 表示您希望廣告請求「不」收到使用者待遇 未滿規定年齡的歐洲經濟區 (EEA) 使用者。

  • 透過以下方式致電setTagForUnderAgeOfConsent()TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED 表示 指定廣告請求是否應該針對 未滿規定年齡的歐洲經濟區 (EEA)。

以下舉例說明您想在廣告請求中加入 TFUA:

Java

RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration()
    .toBuilder()
    .setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE)
    .build();
MobileAds.setRequestConfiguration(requestConfiguration);

Kotlin

var requestConfiguration = MobileAds.getRequestConfiguration()
  .toBuilder()
  .setTagForUnderAgeOfConsent(RequestConfiguration.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE)
  .build()
MobileAds.setRequestConfiguration(requestConfiguration)

用來啟用兒童導向內容設定的代碼 和 setTagForUnderAgeOfConsent() 不可同時設為 true。 如果是這種情況,系統會優先採用兒童導向設定。

廣告素材篩選功能

遵守 Google Play 的不當廣告政策 包含廣告內的相關優惠、所有廣告和相關 應用程式內顯示的優惠必須與內容相關 評分 / 您的應用程式,即使其內容本身符合 Google 規範 Google Play 的政策

廣告內容分級上限等工具 使用者所見廣告的內容您可以將內容分級上限設為 有助於遵守平台政策

應用程式可以使用 setMaxAdContentRating敬上 方法。此畫面設定的內容分級等於或 。其他聯播網的可能值取決於 數位內容標籤分類,必須是以下其中一項: 字串:

  • MAX_AD_CONTENT_RATING_G
  • MAX_AD_CONTENT_RATING_PG
  • MAX_AD_CONTENT_RATING_T
  • MAX_AD_CONTENT_RATING_MA

下列程式碼會設定 RequestConfiguration 物件,藉此指定 傳回的廣告內容應符合「否」這個數位內容標籤標示 高於 G

Java

RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration()
    .toBuilder()
    .setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_G)
    .build();
MobileAds.setRequestConfiguration(requestConfiguration);

Kotlin

var requestConfiguration = MobileAds.getRequestConfiguration()
  .toBuilder()
  .setMaxAdContentRating(RequestConfiguration.MAX_AD_CONTENT_RATING_G)
  .build()
MobileAds.setRequestConfiguration(requestConfiguration)

請參閱下列文章:

發布商隱私權保護措施 (Beta 版)

發布商隱私權保護措施 (PPT) API 是一項選用工具,可讓應用程式指明是否要關閉廣告功能 針對所有採用 setPublisherPrivacyPersonalizationState() 方法。 使用這項功能時,發布商隱私權處理 (PPT) 參數為 將納入工作階段的剩餘期間

根據預設,傳送給 Google 的廣告請求會放送個人化廣告。下列 程式碼會關閉所有廣告請求的廣告個人化功能:

Java

RequestConfiguration requestConfiguration = MobileAds.getRequestConfiguration()
    .toBuilder()
    .setPublisherPrivacyPersonalizationState(PublisherPrivacyPersonalizationState.DISABLED)
    .build();
MobileAds.setRequestConfiguration(requestConfiguration);

Kotlin

var requestConfiguration = MobileAds.getRequestConfiguration()
  .toBuilder()
  .setPublisherPrivacyPersonalizationState(PublisherPrivacyPersonalizationState.DISABLED)
  .build()
MobileAds.setRequestConfiguration(requestConfiguration)

廣告請求

AdManagerAdRequest 物件會收集指定目標 與廣告請求一併送出的資訊

自訂指定目標

您可以傳送自訂鍵/值組合,為 Google Ad Manager 廣告活動 (即 項) 至 AdManagerAdRequest.Builder.addCustomTargeting()

Java

// Example: Pass custom targeting "age=25".
AdManagerAdRequest newRequest = new AdManagerAdRequest.Builder()
    .addCustomTargeting("age", "25")
    .build();

Kotlin

// Example: Pass custom targeting "age=25".
var newRequest = AdManagerAdRequest.Builder()
  .addCustomTargeting("age", "25")
  .build()

您可以透過字串清單,為單一鍵傳遞多個值。舉例來說 而不是只鎖定 25 歲的兒童

.addCustomTargeting("age", Arrays.asList("24", "25", "26"))

請參考 Ad Manager 自訂指定範例 ,瞭解如何在 Android API 試用版應用程式中實作自訂指定目標。

類別排除

您可以使用 addCategoryExclusion()敬上 方法由 AdManagerAdRequest.Builder 提供:

Java

// Example: Exclude "automobile" and "boat" categories.
AdManagerAdRequest newRequest = new AdManagerAdRequest.Builder()
    .addCategoryExclusion("automobile")
    .addCategoryExclusion("boat")
    .build();

Kotlin

// Example: Exclude "automobile" and "boat" categories.
var newRequest = AdManagerAdRequest.Builder()
  .addCategoryExclusion("automobile")
  .addCategoryExclusion("boat")
  .build()

請參閱 Ad Manager 類別排除範例 ,瞭解如何在 Android API 試用版應用程式中導入類別排除。

發布商提供的 ID

您可以設定一個發布商提供的 ID (PPID),用於展示頻率上限、 目標對象區隔和指定目標、廣告依序輪播和其他 目標對象導向的跨裝置廣告放送控制項

以下是設定 PPID 的範例:

Java

AdManagerAdRequest adRequest = new AdManagerAdRequest.Builder()
    .setPublisherProvidedId("AB123456789")
    .build();

Kotlin

var adRequest = AdManagerAdRequest.Builder()
  .setPublisherProvidedId("AB123456789")
  .build()

查看 Ad Manager PPID 範例 在 Android 中導入發布商提供的 ID (PPID) API 試用版應用程式。

發布商提供的信號

你可以透過以下管道傳送目標對象和比對內容資料: 發布商提供的信號 (PPS)。透過 PPS,您就能運用使用者資料來提升 向觀眾傳達目標對象特性 所有出價方 交易類型 (使用 不必分享使用者 ID目標對象 特徵可包括行為和興趣相關資料 (IAB 目標對象 分類 1.1) 和情境 資料 (IAB 內容分類 2.2)。

Java

Bundle extras = new Bundle();
// Set the demographic to an audience with an "Age Range" of 30-34 and an
// interest in mergers and acquisitions.
extras.putIntegerArrayList("IAB_AUDIENCE_1_1", arrayListOf(6,284));
// Set the content to sedan, station wagon and SUV automotive values.
extras.putIntegerArrayList("IAB_CONTENT_2_2", arrayListOf(4,5,6));

AdManagerAdRequest request = new AdManagerAdRequest.Builder()
  .addNetworkExtrasBundle(AdMobAdapter.class, extras)
  .build()

Kotlin

val extras = Bundle()
// Set the demographic to an audience with an "Age Range" of 30-34 and an
// interest in mergers and acquisitions.
extras.putIntegerArrayList("IAB_AUDIENCE_1_1", arrayListOf(6,284))
// Set the content to sedan, station wagon and SUV automotive values.
extras.putIntegerArrayList("IAB_CONTENT_2_2", arrayListOf(4,5,6))

val request = AdRequest.Builder()
  .addNetworkExtrasBundle(AdMobAdapter::class.java, extras)
  .build()

內容網址

如要為指定內容廣告及品牌安全提供內容網址,您可以呼叫 setContentUrl()敬上 建構 AdManagerAdRequest 時請注意以下幾點:

Java

AdManagerAdRequest.Builder builder = new AdManagerAdRequest.Builder();
builder.setContentUrl("https://www.example.com");
AdManagerAdRequest request = builder.build();

Kotlin

val builder = AdManagerAdRequest.Builder()
builder.setContentUrl("https://www.example.com")
val request = builder.build()

品牌安全 (Beta 版)

如果應用程式會根據不同目標對象顯示動態內容, 能夠使用 setNeighboringContentUrls()敬上 方法中AdManagerAdRequest

Java

ArrayList<String> urls = new ArrayList<String>();
urls.add("https://www.mycontenturl1.com");
urls.add("https://www.mycontenturl2.com");
urls.add("https://www.mycontenturl3.com");
urls.add("https://www.mycontenturl4.com");
AdManagerAdRequest requestWithContent = new AdManagerAdRequest.Builder()
    .setNeighboringContentUrls(urls)
    .build();

Kotlin

var urls = mutableListOf("https://www.mycontenturl1.com", "https://www.mycontenturl2.com",
                         "https://www.mycontenturl3.com", "https://www.mycontenturl4.com")
var requestWithContent = AdManagerAdRequest.Builder()
  .setNeighboringContentUrls(urls)
  .build()

.setNeighboringContentUrls().setContentUrl() 的差別在於 用於品牌安全。