啟用測試廣告

本指南說明如何在廣告整合過程中取得測試廣告。開發期間建議使用測試廣告來檢查點擊行為,以免影響預訂廣告活動的統計資料,或造成廣告主需支付費用。

前置作業

測試廣告單元

測試廣告最快的方法,是使用 Google 提供的測試廣告單元。這些廣告單元與您的 Ad Manager 帳戶無關,使用時不會導致帳戶產生無效流量。

以下是各種格式的測試廣告單元,並附有對應的測試廣告素材:

廣告格式 測試廣告單元 ID
應用程式開啟頁面廣告 /21775744923/example/app-open
自動調整橫幅廣告 /21775744923/example/adaptive-banner
固定大小橫幅廣告 /21775744923/example/fixed-size-banner
插頁式廣告 /21775744923/example/interstitial
獎勵廣告 /21775744923/example/rewarded
插頁式獎勵廣告 /21775744923/example/rewarded-interstitial
原生廣告 /21775744923/example/native
原生影片廣告 /21775744923/example/native-video
重點:這些測試廣告單元已在 Ad Manager 中設為放送直接銷售廣告,而這類廣告不會傳回 AdChoices。

啟用測試裝置 (測試模式)

如果想用接近正式上線的廣告進行更嚴謹的測試,您可以設定測試裝置,並使用自己在 Ad Manager 使用者介面建立的廣告單元 ID。

請按照下列步驟新增測試裝置。

在程式輔助下新增測試裝置

如果想在開發應用程式時測試廣告,請按照下列步驟,透過程式註冊測試裝置。

  1. 載入已整合廣告的應用程式,並發出廣告請求。
  2. 在控制台尋找類似下方的訊息:
    <Google> To get test ads on this device, set:
    GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers =
    @[ @"2077ef9a63d2b398840261c8221a0c9b" ];
    將測試裝置 ID 複製到剪貼簿。
  3. 修改程式碼,透過 testDeviceIdentifiers 設定測試裝置 ID:

Swift

let testDeviceIdentifiers = ["2077ef9a63d2b398840261c8221a0c9b"]
MobileAds.shared.requestConfiguration.testDeviceIdentifiers = testDeviceIdentifiers

Objective-C

NSArray *testDeviceIdentifiers = @[ @"2077ef9a63d2b398840261c8221a0c9b" ];
GADMobileAds.sharedInstance.requestConfiguration.testDeviceIdentifiers = testDeviceIdentifiers;
1. 重新執行應用程式。如果是 Google 廣告,頂端中央會顯示「測試模式」標籤 (適用於橫幅、插頁式或獎勵廣告):
For native advanced ads, the headline asset is prepended with the string
**Test mode**.

<img class="screenshot" src="/admob/images/native-testad-ios.png"
 style="max-width:400px;"/>

Ads with this **Test mode** label are safe to click. Requests, impressions, and
clicks on ads in test mode will not show up in your account's reports.

<aside>Mediated ads do <em>NOT</em> render a **Test mode** label. See the section
below for details.</aside>

使用中介服務進行測試

Google 的測試廣告單元只會顯示 Google 廣告。如要測試中介服務設定,則須啟用測試裝置

中介服務廣告「不會」顯示測試模式標籤。您必須確實對每個中介服務聯播網啟用測試廣告,避免帳戶遭標記為存在無效活動。詳情請參閱各聯播網的中介服務指南

如果不確定中介服務廣告聯播網的轉接程式是否提供測試模式,開發期間最好避免點選該聯播網的廣告。您可以透過任何廣告格式的 adNetworkClassName 屬性,瞭解目前顯示的廣告是由哪個聯播網提供。