インライン アダプティブ バナー

アダプティブ バナーは次世代のレスポンシブ広告で、デバイスごとに広告サイズを最適化して広告のパフォーマンスを最大限に高めます。アダプティブ バナーでは、固定の高さしかサポートされない固定サイズのバナーが改善されました。アダプティブ バナーでは、デベロッパーが広告の幅を指定し、それに基づいて最適な広告サイズを判断できます。

最適な広告サイズを選択するために、インライン アダプティブ バナーでは、固定された高さではなく最大の高さが使用されます。これにより、パフォーマンスが向上します。

インライン アダプティブ バナーの用途

インライン アダプティブ バナーは、アンカー アダプティブ バナーよりも大きくて背の高いバナーです。高さは可変で、デバイスの画面と同じ高さにすることができます。

次のようなスクロール コンテンツに配置することを目的としています。

前提条件

  • Google Mobile Ads SDK 8.10.0 以降

始める前に

アプリにアダプティブ バナーを実装する際は、以下の点に留意してください。

  • 広告が配置されるビューの幅を把握しておく必要があります。また、デバイスの幅とセーフエリア(該当する場合)を考慮する必要があります

  • Google Mobile Ads SDK の最新バージョンを使用していることを確認します。また、メディエーションを使用している場合は、最新バージョンのメディエーション アダプタを使用していることを確認してください。

  • インライン アダプティブ バナーのサイズは、利用可能な全幅を使用した場合に最も効果を発揮するように設計されています。ほとんどの場合、これは使用中のデバイスの画面の全幅になります。該当するセーフエリアを必ず考慮してください。

  • アダプティブ サイズを使用するには、広告申込情報の更新または新規作成が必要になることがあります。詳細

実装

インライン アダプティブ バナー広告を実装する手順は、アンカー アダプティブ バナー広告を実装する手順と同じです。唯一の違いは、インライン アダプティブ バナー広告は、インライン アダプティブ バナー広告のサイズを使用して読み込まれることです。インライン アダプティブ広告サイズを作成するには:

  • 使用するデバイスの幅を取得します。画面の全幅を使用しない場合は、独自の幅を設定します。
  • 広告サイズクラスの適切な静的メソッド(例: GADCurrentOrientationInlineBannerAdSizeWithWidth(CGFloat width) )を使用して、選択された向きのインライン アダプティブ広告サイズオブジェクトを取得します。
  • バナーの高さを制限する場合は、静的メソッド GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(CGFloat width, CGFloat maxHeight) を使用します。

次のサンプルコードは、この手順を示しています。

Swift

// Step 1: Create an inline adaptive banner ad size. This size is used to
// request your adaptive banner. You can pass in the width of the device, or set
// your own width. This example sets a static width.
let adSize = GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(320)
// Step 2: Create banner with the inline size and set ad unit ID.
let bannerView = GAMBannerView(adSize: adSize)
bannerView.adUnitID = "ad unit ID"
bannerView.rootViewController = self

// For Ad Manager, the `adSize` property is used for the adaptive banner ad
// size. The `validAdSizes` property is used as normal for the supported
// reservation sizes for the ad placement.
bannerView.validAdSizes = [NSValueFromGADAdSize(GADAdSizeBanner)]

// Step 3: Load an ad.
let request = GAMRequest()
bannerView.load(request)
// TODO: Insert banner view in table view or scroll view, etc.

Objective-C

// Step 1: Create an inline adaptive banner ad size. This size is used to
// request your adaptive banner. You can pass in the width of the device, or set
// your own width. This example sets a static width.
GADAdSize *adSize = GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(320);
// Step 2: Create banner with the inline size and set ad unit ID.
GAMBannerView bannerView = [[GAMBannerView alloc] initWithAdSize:adSize];
bannerView.adUnitID = @"ad unit ID";
bannerView.rootViewController = self;

// For Ad Manager, the adSize property is used for the adaptive banner ad size.
// The validAdSizes property is used as normal for the supported reservation
// sizes for the ad placement. This is optional and only needed if you wish to
// support reservation ad sizes.
bannerView.validAdSizes = @[ NSValueFromGADAdSize(GADAdSizeBanner) ];

// Step 3: Load an ad.
GAMRequest *request = [GAMRequest request];
[bannerView loadRequest:request];
// TODO: Insert banner view in table view or scroll view, etc.

参考情報

GitHub の例

サンプル アプリケーションをダウンロードして、インライン アダプティブ バナーの動作をご確認ください。

Swift Objective-C