本指南說明如何為廣告請求提供指定目標資訊。如需實際範例,請下載 Android API 試用版應用程式。
必要條件
- 完整閱讀入門指南
RequestConfiguration
RequestConfiguration
物件可收集指定目標資訊,然後透過 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 將內容視為兒童導向內容,我們就會針對該廣告請求停用 IBA 和再行銷廣告。
您可透過 RequestConfiguration.Builder.setTagForChildDirectedTreatment(int)
搭配所有版本的 Google Play 服務 SDK 使用這項設定:
呼叫
setTagForChildDirectedTreatment
和TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE
,表明您想將您的內容視為兒童導向內容,以符合 COPPA 規範。這樣做可避免傳輸 Android 廣告 ID (AAID)。使用
TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE
呼叫setTagForChildDirectedTreatment
,表示您不想將您的內容視為兒童導向內容,以符合 COPPA 規定。如果您不想指出您希望內容在廣告請求中遵守 COPPA 的處理方式,請使用
TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED
呼叫setTagForChildDirectedTreatment
。
以下示例表示您希望根據 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)
未滿規定年齡的使用者
您可以替廣告請求設定未滿規定年齡的歐洲經濟區使用者標記這項功能的立意是協助您遵守《一般資料保護規則》(GDPR)。請注意,您可能也需要配合 GDPR 遵守其他法律義務;請查看歐盟指南並諮詢您的法律顧問。請注意,Google 提供工具的用意是協助遵循法規,而非方便發布商規避法定義務。 進一步瞭解 GDPR 對發布商的影響。
使用這項功能時,廣告請求中會納入未滿規定年齡的歐洲使用者 (TFUA) 參數。這個參數會停用所有廣告請求的個人化廣告 (包括再行銷)。這個程式庫也會停用向第三方廣告伺服器 (例如廣告評估像素和第三方廣告伺服器) 發出的要求。
和兒童導向設定一樣,RequestConfiguration.Builder
可以使用的方法設定 TFUA 參數:setTagForUnderAgeOfConsent()
,包含以下選項。
請使用
TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE
呼叫setTagForUnderAgeOfConsent()
,指出您希望廣告請求針對歐洲經濟區 (EEA) 境內未滿規定年齡的使用者進行處理。這樣做也能防止 Android 廣告 ID (AAID) 傳輸。呼叫
setTagForUnderAgeOfConsent()
並指定TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE
,表示您希望廣告請求「不要」為歐洲經濟區 (EEA) 境內未滿規定年齡的使用者發出通知。請使用
TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED
呼叫setTagForUnderAgeOfConsent()
,表示您並未指明廣告請求是否應接收未滿法定同意年齡的歐洲經濟區 (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 Play 的政策規定也一樣。
您可利用廣告內容分級上限這類工具,進一步掌控向使用者放送的廣告內容。您可以設定內容分級上限,以利遵守平台政策。
應用程式可以使用 setMaxAdContentRating
方法,為廣告請求設定廣告內容分級上限。當此設定達到或低於該等級時,就會傳回 AdMob 廣告。這個網路額外項目可能的值是根據數位內容標籤分類,且必須是下列其中一個字串:
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
物件會收集要與廣告請求一併傳送的指定目標資訊。
自訂指定目標
您可以透過 AdManagerAdRequest.Builder.addCustomTargeting()
傳遞自訂鍵/值組合,指定 Google Ad Manager 廣告活動 (委刊項):
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 試用版應用程式中實作自訂指定。
類別排除
您可以使用 AdManagerAdRequest.Builder
提供的 addCategoryExclusion()
方法,將版位層級的類別排除層級新增至要求:
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()
如需在 Android API 試用版應用程式中實作類別排除功能,請參閱 Ad Manager 類別排除範例。
發布商提供的 ID
您可以設定發布商提供的 ID (PPID),以便用於展示頻率上限、目標對象區隔和指定目標、廣告依序輪播,以及其他以目標對象為基礎的跨裝置廣告放送控制項。
以下是設定 PPID 的範例:
Java
AdManagerAdRequest adRequest = new AdManagerAdRequest.Builder()
.setPublisherProvidedId("AB123456789")
.build();
Kotlin
var adRequest = AdManagerAdRequest.Builder()
.setPublisherProvidedId("AB123456789")
.build()
如需在 Android API 試用版應用程式中實作發布商提供的 ID (PPID),請參閱 Ad Manager PPID 範例。
發布商提供的信號
您可以在廣告請求中,以發布商提供的信號 (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()
內容網址
如要為內容指定廣告和品牌安全提供內容網址,您可以在建立 AdManagerAdRequest
時呼叫 setContentUrl()
:
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 版)
如果應用程式會根據不同的目標對象顯示動態內容,可以在建構 AdManagerAdRequest
時使用 setNeighboringContentUrls()
方法提供簡短的網址清單:
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()
的差別在於 此 僅用於品牌安全。