可收合橫幅廣告

選取平台: Android iOS Unity Flutter

可收合橫幅廣告是橫幅廣告的一種,一開始會以較大尺寸重疊在畫面上,點按廣告上的按鈕後,就會收合為原始請求的橫幅廣告大小。可收合橫幅廣告的作用,是提升原本尺寸較小的錨定廣告成效。本指南說明如何為現有的橫幅廣告刊登位置,啟用可收合橫幅廣告。

必備條件

導入作業

請確認您已依據使用者在一般 (收合) 橫幅狀態下看到的尺寸,來定義橫幅廣告檢視區塊。接著在廣告請求中加入 extras 參數,將 collapsible 設為鍵,並將廣告刊登位置設為值。

可收合刊登位置會定義展開區域與橫幅廣告之間的錨定關係。

Placement 行為 預定位置
top 廣告展開與收合時上緣對齊。 廣告位於畫面頂端。
bottom 廣告展開與收合時底部對齊。 廣告位於畫面底部。

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

void _loadAd() async {
  // Replace these test ad units with your own ad units.
  final String adUnitId = Platform.isAndroid
    ? 'ca-app-pub-3940256099942544/2014213617'
    : 'ca-app-pub-3940256099942544/8388050270';

  // Get the size before loading the ad.
  final size = await AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
      MediaQuery.sizeOf(context).width.truncate());

  if (size == null) {
    // Unable to get the size.
    return;
  }

  // Create an extra parameter that aligns the bottom of the expanded ad to the
  // bottom of the banner ad.
  const adRequest = AdRequest(extras: {
    "collapsible": "bottom",
  });

  BannerAd(
      adUnitId: adUnitId,
      request: adRequest,
      size: size,
      listener: const BannerAdListener()
  ).load();
}

廣告重新整理行為

如果在 Ad Manager 網頁介面中,設定自動重新整理應用程式內的橫幅廣告,當某個橫幅廣告版位請求到可收合橫幅廣告,後續更新將不再請求這類廣告,因為每次更新都重新展開廣告,可能對使用者體驗造成負面影響。

如果想在同一工作階段內再次載入可收合橫幅廣告,可以手動發送包含 collapsible 參數的廣告請求。

中介服務

可收合橫幅廣告僅適用於 Google 廣告需求。透過中介服務放送的廣告,會顯示為不可收合的一般橫幅廣告。