可收合橫幅廣告

可收合橫幅廣告是一種橫幅廣告,一開始會以較大的重疊廣告呈現,您可以透過按鈕將其收合為原本請求的橫幅廣告大小。可收合橫幅廣告旨在提升錨定廣告的成效,這類廣告的尺寸較小。本指南將說明如何為現有的橫幅廣告刊登位置啟用可收合橫幅廣告。

先備知識

導入作業

請確認您的橫幅檢視畫面定義了您希望使用者在一般 (收合) 橫幅狀態中看到的大小。在廣告請求中加入額外參數,並以 collapsible 做為鍵,並將廣告刊登位置設為廣告位置。

可收合刊登位置會定義展開區域錨定到橫幅廣告的方式。

Placement 行為 預期用途
top 展開廣告頂端會對齊收合廣告的頂端, 廣告位於畫面頂端。
bottom 展開廣告底部會對齊收合廣告的底部。 廣告位於畫面底部。

如果載入的廣告是可收合橫幅廣告,移至檢視區塊階層後,橫幅廣告會立即顯示可收合重疊廣告。

Swift

func loadBannerAd() {
   bannerView.adUnitID = "ca-app-pub-3940256099942544/8388050270"
   bannerView.rootViewController = self
   let viewWidth = FRAME_WIDTH
   bannerView.adSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth)

   let request = GADRequest()

   // Create an extra parameter that aligns the bottom of the expanded ad to
   // the bottom of the bannerView.
   let extras = GADExtras()
   extras.additionalParameters = ["collapsible" : "bottom"]
   request.register(extras)

   bannerView.load(request)
 }

Objective-C

- (void)loadBannerAd {
  self.bannerView.adUnitID = @"ca-app-pub-3940256099942544/8388050270";
  CGFloat viewWidth = FRAME_WIDTH;
  self.bannerView.adSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth);

  GADRequest *request = [GADRequest request];

  // Create an extra parameter that aligns the bottom of the expanded ad to the
  // bottom of the bannerView.
  GADExtras *extras = [[GADExtras alloc] init];
  extras.additionalParameters = @{@"collapsible" : @"bottom"};
  [request registerAdNetworkExtras:extras];

  [self.bannerView loadRequest:request];
}

廣告重新整理行為

如果應用程式在 Ad Manager 網頁介面中為橫幅廣告設定自動重新整理,當系統為橫幅廣告版位請求可收合橫幅廣告時,系統後續重新整理廣告就不會請求可收合橫幅廣告。這是因為每次重新整理時都顯示可收合橫幅廣告,可能會對使用者體驗造成負面影響。

如果您想在工作階段中的一段時間後載入其他可收合橫幅廣告,可在請求中包含可收合橫幅廣告參數,然後手動載入廣告。

檢查載入的廣告是否可收合

呼叫 isCollapsible 檢查最後一個載入的橫幅是否可收合。 如果要求無法載入,且上一個橫幅可收合,則 API 會傳回 true。

Swift

func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
  print("The last loaded banner is \(bannerView.isCollapsible ? "" : "not") collapsible.")
}

Objective-C

- (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {
  NSLog(@"The last loaded banner is %@collapsible.", (bannerView.isCollapsible ? @"" : @"not "));
}

中介服務

可收合橫幅廣告在 Beta 版測試階段僅適用於 Google 廣告需求。透過中介服務放送的廣告,將會恢復正常的不可收合橫幅廣告。

廣告放送行為

為爭取橫幅廣告的成效,如果廣告不支援較大的可收合重疊廣告,系統可能會傳回部分可收合橫幅廣告請求,並在一般的橫幅廣告大小中立即顯示。