本指南說明如何為廣告請求提供指定目標資訊。
必要條件
- 完成開始使用。
RequestConfiguration
RequestConfiguration
結構體會收集指定目標資訊,然後透過 SetRequestConfiguration()
全域函式在全域套用。
如要更新要求設定,請先取得目前的設定,執行所需的更新,然後依照以下方式設定:
firebase::gma::RequestConfiguration retrieved_configuration = firebase::gma::GetRequestConfiguration(); // .. apply your changes, then: firebase::gma::SetRequestConfiguration(request_configuration);
兒童導向設定
根據兒童網路隱私保護法 (COPPA) 規定,我們提供名為「兒童導向內容標記」的設定。設定此標記,即表示您確認這則通知正確無誤,且您有權代表應用程式的擁有者行事。您瞭解濫用這項設定可能會導致 Google 帳戶遭到終止。
如果您是應用程式開發人員,則可指明是否希望 Google 在您提出廣告請求時將您的內容視為兒童導向內容。如果您表明希望 Google 將內容視為兒童導向內容,我們會採取相應措施,針對該廣告請求停用 IBA 和再行銷廣告。
只要將 RequestConfiguration
結構的 tag_for_child_directed_treatment
成員指派給下列其中一個列舉值,即可進行設定:
- 將
RequestConfiguration::tag_for_child_directed_treatment
指派給RequestConfiguration::kChildDirectedTreatmentTrue
,表明您想將您的內容視為兒童導向內容,以符合 COPPA 規範。 - 將
RequestConfiguration::tag_for_child_directed_treatment
指派給RequestConfiguration::kChildDirectedTreatmentFalse
,表明您不希望 Google 將您的內容視為兒童導向內容,以符合 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::tag_for_under_age_of_consent
指派給RequestConfiguration::kUnderAgeOfConsentTrue
,表明您希望廣告請求對歐洲經濟區 (EEA) 境內未滿規定年齡的使用者處理。 - 將
RequestConfiguration::tag_for_under_age_of_consent
指派給RequestConfiguration::kUnderAgeOfConsentFalse
,表明您不希望廣告請求針對歐洲經濟區 (EEA) 境內未滿規定年齡的使用者提供的內容。 - 將
RequestConfiguration::tag_for_under_age_of_consent
指派給RequestConfiguration::kUnderAgeOfConsentUnspecified
,表示您並未指定廣告請求是否應針對歐洲經濟區 (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。如果這兩者同時這樣設定,則以兒童導向設定為優先。
廣告內容篩選
應用程式可以透過 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();