可收合橫幅廣告
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
可收合橫幅廣告是橫幅廣告的一種,一開始會以較大尺寸重疊在畫面上,點按廣告上的按鈕後,就會收合為原始請求的橫幅廣告大小。可收合橫幅廣告的作用,是提升原本尺寸較小的錨定廣告成效。本指南說明如何為現有橫幅廣告的刊登位置啟用可收合橫幅廣告。

必備條件
導入作業
請確認您已依據使用者在一般 (收合) 橫幅狀態下看到的尺寸,來定義橫幅廣告檢視區塊。接著在廣告請求中加入 extras 參數,將 collapsible
設為鍵,並將廣告刊登位置設為值。
可收合刊登位置會定義展開區域與橫幅廣告之間的錨定關係。
Placement 值 |
行為 |
預期應用情境 |
top |
展開廣告的頂端會與收合廣告的頂端對齊。 |
廣告位於畫面頂端。 |
bottom |
展開廣告的底部會與收合廣告的底部對齊。 |
廣告位於畫面底部。 |
如果載入可收合橫幅廣告,廣告加入檢視區塊階層後,就會立即顯示可收合的疊加層。
Swift
func loadBannerAd() {
bannerView.adUnitID = "ca-app-pub-3940256099942544/8388050270"
bannerView.rootViewController = self
let viewWidth = FRAME_WIDTH
bannerView.adSize = currentOrientationAnchoredAdaptiveBanner(width: viewWidth)
let request = Request
// Create an extra parameter that aligns the bottom of the expanded ad to
// the bottom of the bannerView.
let extras = Extras()
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];
}
廣告重新整理行為
對於在 AdMob 網頁介面,為橫幅廣告設定了自動重新整理功能的應用程式而言,如果系統已為橫幅廣告版位請求可收合橫幅廣告,後續重新整理廣告時就不會再請求這類廣告。這是因為若每次重新整理都顯示可收合橫幅廣告,可能會對使用者體驗造成負面影響。
如果之後想在同一工作階段再次載入可收合橫幅廣告,可以手動發送包含 collapsible 參數的請求。
檢查載入的廣告是否可收合
為盡可能提高成效,即使是可收合橫幅廣告請求,系統也允許傳回不可收合橫幅廣告。呼叫 isCollapsible
即可檢查載入的最後一個橫幅廣告能否收合。如果無法順利載入請求,且先前的橫幅廣告可收合,API 便會傳回 true。
Swift
func bannerViewDidReceiveAd(_ bannerView: BannerView) {
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 "));
}
可收合橫幅廣告僅適用於 Google 廣告需求。透過中介服務放送的廣告,會顯示為不可收合的一般橫幅廣告。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-02 (世界標準時間)。
[null,null,["上次更新時間:2025-09-02 (世界標準時間)。"],[[["\u003cp\u003eCollapsible banner ads initially appear larger and can be collapsed by users to the original banner size, improving the performance of smaller, anchored ads.\u003c/p\u003e\n"],["\u003cp\u003eTo implement, define the banner view's collapsed size and include an extras parameter in the ad request specifying the collapsible placement (\u003ccode\u003etop\u003c/code\u003e or \u003ccode\u003ebottom\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eWhile auto-refresh is enabled, subsequent refreshes won't automatically request collapsible banners to maintain a positive user experience; manual requests are needed to load another collapsible banner.\u003c/p\u003e\n"],["\u003cp\u003eYou can verify if a loaded ad is collapsible using the \u003ccode\u003eisCollapsible\u003c/code\u003e property, which also returns true if the request fails but the previous banner was collapsible.\u003c/p\u003e\n"],["\u003cp\u003eCurrently, collapsible banner ads are only supported for Google demand during the beta period; mediated ads will display as regular banners.\u003c/p\u003e\n"]]],["Collapsible banner ads expand from a smaller banner size to a larger overlay. To implement, define the desired collapsed banner size and include an \"extras\" parameter in the ad request with the key \"collapsible\" and the desired `top` or `bottom` placement value. Subsequent ad refreshes won't request collapsible banners automatically. Developers can manually load collapsible ads or check if a loaded ad is collapsible using the `isCollapsible` method. Collapsible banner ads are only available for google demand.\n"],null,["Select platform: [Android](/admob/android/banner/collapsible \"View this page for the Android platform docs.\") [iOS](/admob/ios/banner/collapsible \"View this page for the iOS platform docs.\") [Unity](/admob/unity/banner/collapsible \"View this page for the Unity platform docs.\") [Flutter](/admob/flutter/banner/collapsible \"View this page for the Flutter platform docs.\")\n\n\u003cbr /\u003e\n\nCollapsible banner ads are banner ads that are initially presented as a larger\noverlay, with a button to collapse them to the originally requested banner size.\nCollapsible banner ads are intended to improve performance of anchored ads that\nare otherwise a smaller size. This guide shows how to turn on collapsible banner\nads for existing banner placements.\n\nPrerequisites\n\n- Complete the [banner ads get started guide](/admob/ios/banner).\n\nImplementation\n\nMake sure your banner view is defined with the size you would like users to see\nin the regular (collapsed) banner state. Include an extras parameter in the ad\nrequest with `collapsible` as the key and the placement of the ad as the value.\n\nThe collapsible placement defines how the expanded region anchors to the banner\nad.\n\n| `Placement` value | Behavior | Intended use case |\n|-------------------|-------------------------------------------------------------------------|-----------------------------------------------|\n| `top` | The top of the expanded ad aligns to the top of the collapsed ad. | The ad is placed at the top of the screen. |\n| `bottom` | The bottom of the expanded ad aligns to the bottom of the collapsed ad. | The ad is placed at the bottom of the screen. |\n\nIf the loaded ad is a collapsible banner, the banner shows the collapsible\noverlay immediately once it's placed in the view hierarchy.\n\nSwift \n\n func loadBannerAd() {\n bannerView.adUnitID = \"ca-app-pub-3940256099942544/8388050270\"\n bannerView.rootViewController = self\n let viewWidth = FRAME_WIDTH\n bannerView.adSize = currentOrientationAnchoredAdaptiveBanner(width: viewWidth)\n\n let request = Request\n\n // Create an extra parameter that aligns the bottom of the expanded ad to\n // the bottom of the bannerView.\n let extras = Extras()\n extras.additionalParameters = \\[\"collapsible\" : \"bottom\"\\]\n request.register(extras)\n\n bannerView.load(request)\n }\n\nObjective-C \n\n - (void)loadBannerAd {\n self.bannerView.adUnitID = @\"ca-app-pub-3940256099942544/8388050270\";\n CGFloat viewWidth = FRAME_WIDTH;\n self.bannerView.adSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth);\n\n GADRequest *request = [GADRequest request];\n\n // Create an extra parameter that aligns the bottom of the expanded ad to the\n // bottom of the bannerView.\n GADExtras \\*extras = \\[\\[GADExtras alloc\\] init\\];\n extras.additionalParameters = @{@\"collapsible\" : @\"bottom\"};\n \\[request registerAdNetworkExtras:extras\\];\n\n [self.bannerView loadRequest:request];\n }\n\n\u003cbr /\u003e\n\nAds refreshing behavior\n\nFor apps that configure auto-refresh for banner ads in the\nAdMob web interface, when a collapsible banner ad\nis requested for a banner slot, subsequent ad refreshes won't request\ncollapsible banner ads. This is because showing a collapsible banner on every\nrefresh could have a negative impact on user experience.\n\nIf you want to load another collapsible banner ad later in the session, you can\nload an ad manually with a request containing the collapsible parameter.\n\nCheck if a loaded ad is collapsible\n\nNon-collapsible banner ads are eligible to return for collapsible banner\nrequests to maximize performance. Call `isCollapsible` to check if the last\nbanner loaded is collapsible. If the request fails to load and the previous\nbanner is collapsible, the API returns true. \n\nSwift \n\n func bannerViewDidReceiveAd(_ bannerView: BannerView) {\n print(\"The last loaded banner is \\(bannerView.isCollapsible ? \"\" : \"not\") collapsible.\")\n }\n\nObjective-C \n\n - (void)bannerViewDidReceiveAd:(GADBannerView *)bannerView {\n NSLog(@\"The last loaded banner is %@collapsible.\", (bannerView.isCollapsible ? @\"\" : @\"not \"));\n }\n\n\u003cbr /\u003e\n\nMediation\n\nCollapsible banner ads are only available for Google demand. Ads served through\nmediation show as normal, non-collapsible banner ads."]]