本指南介绍如何为广告请求提供定位信息。
前提条件
- 完成入门指南的学习。
RequestConfiguration
RequestConfiguration
是一个结构体,可通过 SetRequestConfiguration()
全局函数收集要全局应用的定位信息。
如需更新请求配置,请先获取当前配置,执行任何所需的更新,然后按如下所示进行设置:
firebase::gma::RequestConfiguration retrieved_configuration = firebase::gma::GetRequestConfiguration(); // .. apply your changes, then: firebase::gma::SetRequestConfiguration(request_configuration);
面向儿童的设置
为了遵守《儿童在线隐私保护法》(COPPA) 的规定,我们提供了一项名为“标记为面向儿童的内容”的设置。设置此标记,即表示您确认此通知准确无误,且您有权代表应用的所有者行事。您了解,滥用此设置可能会导致您的 Google 帐号被终止。
作为应用开发者,您可以在发出广告请求时表明是否希望 Google 将您的内容视为面向儿童的内容。如果您表明希望 Google 将您的内容视为面向儿童的内容,我们会采取相应措施,在该广告请求中停用针对用户兴趣投放广告和再营销广告。
您可以通过将 RequestConfiguration
结构体的 tag_for_child_directed_treatment
成员分配给以下某个枚举值来配置此设置:
- 为
RequestConfiguration::kChildDirectedTreatmentTrue
分配RequestConfiguration::tag_for_child_directed_treatment
,以表明您希望根据《儿童在线隐私保护法》(COPPA) 的规定将您的内容视为面向儿童的内容。 - 为
RequestConfiguration::kChildDirectedTreatmentFalse
分配RequestConfiguration::tag_for_child_directed_treatment
,以表明您不希望根据《儿童在线隐私保护法》(COPPA) 的规定将您的内容视为面向儿童的内容。 - 如果您不想在广告请求中表明您想如何根据《儿童在线隐私保护法》(COPPA) 的规定来认定您的内容,请将
RequestConfiguration::tag_for_child_directed_treatment
分配给RequestConfiguration::kChildDirectedTreatmentUnspecified
。
以下示例表明您希望根据《儿童在线隐私保护法》(COPPA) 的规定将您的内容视为面向儿童的内容:
firebase::gma::RequestConfiguration request_configuration = firebase::gma::GetRequestConfiguration(); request_configuration.tag_for_child_directed_treatment = firebase::RequestConfiguration::kChildDirectedTreatmentTrue; firebase::gma::SetRequestConfiguration(request_configuration);
设置此标记,即表示您确认此通知准确无误,且您有权代表应用的所有者行事。您了解,滥用此设置可能会导致您的 Google 帐号被终止。
未达到同意年龄的用户
您可以对广告请求进行标记,确保针对未达到法定承诺年龄的欧洲经济区 (EEA) 用户投放的是合适的广告。这项功能旨在帮助您遵守一般数据保护条例 (GDPR)。请注意,您可能还须承担 GDPR 规定的其他法律义务。具体请查看欧盟发布的指导原则,并咨询您自己的法律顾问。另外请注意,Google 的工具旨在协助发布商遵守法规,但并不能免除任何特定发布商按照法律规定所需承担的义务。详细了解 GDPR 给发布商带来了哪些影响。
使用这项功能时,广告请求中会包含一个用于表示用户位于欧洲且未达到法定承诺年龄的标记 (TFUA) 参数。此参数会禁止针对所有广告请求投放个性化广告,包括再营销广告。它还禁止向第三方广告供应商(例如广告衡量像素和第三方广告服务器)发送请求。
与面向儿童的设置一样,RequestConfiguration 中有一个成员用于配置 TFUA 参数:tag_for_under_age_of_consent
,该参数可使用以下枚举值进行配置:
- 为
RequestConfiguration::kUnderAgeOfConsentTrue
分配RequestConfiguration::tag_for_under_age_of_consent
,即表明您希望按适合未达到法定承诺年龄的欧洲经济区 (EEA) 用户的方式处理该广告请求。 - 为
RequestConfiguration::kUnderAgeOfConsentFalse
分配RequestConfiguration::tag_for_under_age_of_consent
,即表明您不希望按适合未达到法定承诺年龄的欧洲经济区 (EEA) 用户的方式处理该广告请求。 - 为
RequestConfiguration::kUnderAgeOfConsentUnspecified
分配RequestConfiguration::tag_for_under_age_of_consent
,以表示您尚未指定广告请求是否应面向未达到同意年龄的欧洲经济区 (EEA) 用户。
以下示例表明您希望广告请求中包含 TFUA 标记:
firebase::gma::RequestConfiguration request_configuration = firebase::gma::GetRequestConfiguration(); request_configuration.tag_for_under_age_of_consent = firebase::RequestConfiguration::kUnderAgeOfConsentTrue; firebase::gma::SetRequestConfiguration(request_configuration);
不应将用于启用“面向儿童”的设置和未达到法定承诺年龄的用户的标记同时设置为 true。如果同时设置为 true,则以“面向儿童的设置”为准。
广告内容过滤
应用可以通过 RequestConfiguration::max_ad_content_rating field
为其广告请求设置广告内容分级上限。如果配置了此方法,所返回的 AdMob 广告的内容分级会等于或低于该上限。此字段可能的值依数字内容标签分类而定,并且必须是以下枚举值之一:
RequestConfiguration::kMaxAdContentRatingG
RequestConfiguration::kMaxAdContentRatingPG
RequestConfiguration::kMaxAdContentRatingT
RequestConfiguration::kMaxAdContentRatingMA
以下代码会配置 RequestConfiguration
结构体,以指定返回的广告内容所对应的数字内容标签不应高于 G:
firebase::gma::RequestConfiguration request_configuration = firebase::gma::GetRequestConfiguration(); request_configuration.max_ad_content_rating = firebase::RequestConfiguration::kMaxAdContentRatingG; firebase::gma::SetRequestConfiguration(request_configuration);
AdRequest
AdRequest
对象可收集随广告请求一起发送的定位信息。
内容网址
在请求广告时,应用可以传递其正在处理的内容的网址。这样就能进行关键字定位,从而将广告与内容进行匹配。
例如,如果您的应用在显示来自 https://www.example.com
的内容时请求广告,则可传递此网址定位相关的关键字:
// AdRequest with content URL: firebase::admob::AdRequest ad_request(/*content_url=*/"https://www.example.com"); // AdRequest without content URL: firebase::admob::AdRequest ad_request();