本指南說明如何向 Google Mobile Ads SDK 提供目標對象資訊。
修課條件
- 完成入門指南的步驟。
RequestConfiguration
RequestConfiguration
會收集套用至每個廣告請求的指定目標資訊。如需可用的指定目標標記,請參閱 RequestConfiguration.Builder
說明文件。
使用建構工具建立 RequestConfiguration
物件,並加入所需的指定目標代碼,然後呼叫 MobileAds.setRequestConfiguration()
設定。
Kotlin
val requestConfiguration = RequestConfiguration
.Builder()
// Set your targeting tags.
.setTagForChildDirectedTreatment(RequestConfiguration.TagForChildDirectedTreatment.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)
.build()
MobileAds.setRequestConfiguration(requestConfiguration)
Java
RequestConfiguration requestConfiguration = new RequestConfiguration
.Builder()
// Set your targeting tags.
.setTagForChildDirectedTreatment(TagForChildDirectedTreatment.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)
.build();
MobileAds.setRequestConfiguration(requestConfiguration);
如要套用第一個廣告請求中的指定目標標記,請在 SDK 初始化期間提供請求設定:
Kotlin
val requestConfiguration = RequestConfiguration
.Builder()
// Set your targeting tags.
.setTagForChildDirectedTreatment(RequestConfiguration.TagForChildDirectedTreatment.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)
.build()
CoroutineScope(Dispatchers.IO).launch {
// Initialize Google Mobile Ads SDK (beta) on a background thread.
MobileAds.initialize(
this@MainActivity,
InitializationConfig
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
.Builder("SAMPLE_APP_ID")
.setRequestConfiguration(requestConfiguration)
.build()
) {
// Adapter initialization is complete.
}
// Other methods on MobileAds can now be called.
}
Java
RequestConfiguration requestConfiguration = new RequestConfiguration
.Builder()
// Set your targeting tags.
.setTagForChildDirectedTreatment(TagForChildDirectedTreatment.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)
.build();
new Thread(
() -> {
// Initialize Google Mobile Ads SDK (beta) on a background thread.
MobileAds.initialize(
this,
// Sample AdMob app ID: ca-app-pub-3940256099942544~3347511713
new InitializationConfig
.Builder("SAMPLE_APP_ID")
.setRequestConfiguration(requestConfiguration)
.build(),
initializationStatus -> {
// Adapter initialization is complete.
});
// Other methods on MobileAds can now be called.
})
.start();
兒童導向內容設定
為符合《兒童網路隱私保護法》(COPPA),系統支援「兒童導向內容標記」設定。設定此標記,代表您保證這項通知資訊正確無誤,且您有權代表應用程式擁有者行事。您知悉濫用這項設定可能導致 Google 帳戶遭終止。
應用程式開發人員可以在傳送廣告請求時,指明是否希望 Google 將內容標為兒童導向。如果希望 Google 將內容視為兒童導向,我們就會採取相關行動,對該廣告請求停用「依興趣指定目標對象」(IBA) 功能和再行銷廣告。
您可以使用 setTagForChildDirectedTreatment()
套用兒童導向內容設定:
呼叫
setTagForChildDirectedTreatment
並傳遞TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE
,指明要根據 COPPA 將內容視為兒童導向,這樣系統就不會傳送 Android 廣告 ID (AAID)。呼叫
setTagForChildDirectedTreatment
並傳遞TAG_FOR_CHILD_DIRECTED_TREATMENT_FALSE
,指明不要根據 COPPA 將內容視為兒童導向。如不想在廣告請求中指明是否依 COPPA 規定處理內容,請呼叫
setTagForChildDirectedTreatment
並傳遞TAG_FOR_CHILD_DIRECTED_TREATMENT_UNSPECIFIED
。
以下範例說明如何依 COPPA 規定,將內容標示為兒童導向:
Kotlin
val requestConfiguration = RequestConfiguration
.Builder()
.setTagForChildDirectedTreatment(RequestConfiguration.TagForChildDirectedTreatment.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)
.build()
MobileAds.setRequestConfiguration(requestConfiguration)
Java
RequestConfiguration requestConfiguration = new RequestConfiguration
.Builder()
.setTagForChildDirectedTreatment(TagForChildDirectedTreatment.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE)
.build();
MobileAds.setRequestConfiguration(requestConfiguration);
未滿規定年齡的使用者
針對未滿規定年齡的歐洲經濟區使用者,您可以在廣告請求中加上相關處理標記。這項功能是為協助發布商遵守《一般資料保護規則》(GDPR)。請注意,根據 GDPR 規定,您可能還有其他法律義務。建議參考歐盟官方指引,並諮詢您的法律顧問。請注意,Google 提供工具的用意是協助發布商遵守規定,發布商不可濫用工具規避法定義務。進一步瞭解 GDPR 對發布商的影響。
使用這項功能時,廣告請求會包含歐洲使用者適用的未滿規定年齡標記 (TFUA) 參數。這項參數會停用所有廣告請求的個人化廣告功能 (包括再行銷),並停止向第三方廣告供應商 (例如廣告評估像素和第三方廣告伺服器) 提出其他請求。
就像兒童導向內容設定,您可以用 RequestConfiguration.Builder
中的方法 setTagForUnderAgeOfConsent()
設定 TFUA 參數,可用的選項包括:
呼叫
setTagForUnderAgeOfConsent()
並傳遞TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE
,指明要對涉及歐洲經濟區內未滿規定年齡使用者的廣告請求,套用適當模式,且這也可防止系統傳送 Android 廣告 ID (AAID)。呼叫
setTagForUnderAgeOfConsent()
並傳遞TAG_FOR_UNDER_AGE_OF_CONSENT_FALSE
,指明「不要」對涉及歐洲經濟區內未滿規定年齡使用者的廣告請求,套用相關模式。如未指明對涉及歐洲經濟區內未滿規定年齡使用者的廣告請求,套用相關模式,請呼叫
setTagForUnderAgeOfConsent()
並傳遞TAG_FOR_UNDER_AGE_OF_CONSENT_UNSPECIFIED
。
以下範例說明如何在廣告請求中加入 TFUA:
Kotlin
val requestConfiguration = RequestConfiguration
.Builder()
.setTagForUnderAgeOfConsent(RequestConfiguration.TagForUnderAgeOfConsent.TAG_FOR_UNDER_AGE_OF_CONSENT_TRUE)
.build()
MobileAds.setRequestConfiguration(requestConfiguration)
Java
RequestConfiguration requestConfiguration = new RequestConfiguration
.Builder()
.setTagForUnderAgeOfConsent(TagForUnderAgeOfConsent.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
:
Kotlin
val requestConfiguration = RequestConfiguration
.Builder()
.setMaxAdContentRating(RequestConfiguration.MaxAdContentRating.MAX_AD_CONTENT_RATING_G)
.build()
MobileAds.setRequestConfiguration(requestConfiguration)
Java
RequestConfiguration requestConfiguration = new RequestConfiguration
.Builder()
.setMaxAdContentRating(MaxAdContentRating.MAX_AD_CONTENT_RATING_G)
.build();
MobileAds.setRequestConfiguration(requestConfiguration);
請參閱下列文章:
發布商隱私權處理方式 (Beta 版)
如有需要可選用 Publisher Privacy Treatment (PPT) API,這樣應用程式便可使用 setPublisherPrivacyPersonalizationState()
方法,指明是否要停用所有廣告請求的廣告個人化設定。如果採用這項功能,則工作階段後續所有的廣告請求,都會加入 Publisher Privacy Treatment (PPT) 參數。
根據預設,向 Google 請求的廣告一律會採用個人化功能。下列程式碼可停用所有廣告請求的廣告個人化設定:
Kotlin
val requestConfiguration = RequestConfiguration
.Builder()
.setPublisherPrivacyPersonalizationState(RequestConfiguration.PublisherPrivacyPersonalizationState.DISABLED)
.build()
MobileAds.setRequestConfiguration(requestConfiguration)
Java
RequestConfiguration requestConfiguration = new RequestConfiguration
.Builder()
.setPublisherPrivacyPersonalizationState(RequestConfiguration.PublisherPrivacyPersonalizationState.DISABLED)
.build();
MobileAds.setRequestConfiguration(requestConfiguration);
廣告請求
AdRequest
物件會收集指定目標資訊,並與廣告請求一併傳送。
新增電視網額外資訊
聯播網額外資訊是隨廣告請求傳送的附加詳細資料,只適用於特定廣告來源。
以下程式碼片段是將額外資訊參數鍵 collapsible
設為 bottom
值,並傳送給 Google:
Kotlin
val extras = Bundle()
extras.putString("collapsible", "bottom")
val adRequest =
NativeAdRequest.Builder("AD_UNIT_ID", listOf(NativeAd.NativeAdType.NATIVE))
.setGoogleExtrasBundle(extras)
.build()
NativeAdLoader.load(adRequest, adCallback)
Java
Bundle extras = new Bundle();
extras.putString("collapsible", "bottom");
NativeAdRequest adRequest =
new NativeAdRequest.Builder("AD_UNIT_ID", Arrays.asList(NativeAd.NativeAdType.NATIVE))
.setGoogleExtrasBundle(extras)
.build();
NativeAdLoader.load(adRequest, adCallback);