啟用測試廣告

本指南說明如何接收廣告整合的測試廣告。建議您在開發期間使用測試廣告,這樣就能測試點擊行為,不會影響預訂廣告活動的統計資料,也不會向廣告主收費。

修課條件

  • 完成「開始使用」

示範廣告單元

想要測試廣告,最快的方法是使用 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 屬性,找出放送目前廣告的廣告聯播網。