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

プラットフォームを選択: Android iOS Flutter

アダプティブ バナーでは、指定した広告の幅に応じて、最適な広告サイズが決定されます。また、デバイスに合わせて広告サイズが最適化されるため、パフォーマンスを最大限に高めることができます。これにより、広告のパフォーマンスの向上が見込めます。

アンカー アダプティブ バナーと比べて、インライン アダプティブ バナーは大きく高さがあります。また高さは固定されず、変動します。インライン アダプティブ バナーは高さが変動するフォーマットのため、画面全体に表示したり、指定した最大の高さで表示したりできます。

インライン アダプティブ バナーは、次のようなスクロールできるコンテンツに配置します。

アダプティブ バナーとインライン アダプティブ バナーの違いを示した図

始める前に

続行する前に、次の点をご確認ください。

アダプティブ バナーを実装する

アンカー アダプティブ バナーとは異なり、インライン アダプティブ バナーはインライン アダプティブ バナーのサイズを使用して読み込まれます。インライン アダプティブ広告サイズを作成するには、次の手順を行います。

  1. 広告を掲載するデバイスの幅を取得します。デバイス画面の幅全体を使用しない場合は、任意の幅を設定します。

  2. 広告サイズクラスの適切な静的メソッド(GADCurrentOrientationInlineBannerAdSizeWithWidth(CGFloat width) など)を使用して、指定した向きのインライン アダプティブ広告サイズ オブジェクトを取得します。

    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 = GADBannerView(adSize: adSize)
    bannerView.adUnitID = "AD_UNIT_ID"
    bannerView.rootViewController = self
    
    // Step 3: Load an ad.
    let request = Request()
    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.
    GADBannerView bannerView = [[GADBannerView alloc] initWithAdSize:adSize];
    bannerView.adUnitID = @"AD_UNIT_ID";
    bannerView.rootViewController = self;
    
    // Step 3: Load an ad.
    GADRequest *request = [GADRequest request];
    [bannerView loadRequest:request];
    // TODO: Insert banner view in table view or scroll view, etc.
    

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

    • インライン アダプティブ バナーは、利用できるスペースの横幅いっぱいに表示すると最も効果を発揮するように設計されています。ほとんどの場合、このサイズは使用しているデバイス画面の全幅、またはバナーの親コンテンツの全幅です。広告を配置する画面の幅、デバイスの幅、親コンテンツの幅、該当するセーフエリアを把握している必要があります。

    インライン アダプティブ バナーのサイズの向きを指定する

    特定の画面の向きでインライン アダプティブ バナー広告をプリロードするには、次のメソッドを使用します。

    アプリが縦向きと横向きの両方の画面表示に対応しており、現在のデバイスの向きでアダプティブ バナー広告をプリロードするには、GADCurrentOrientationInlineAdaptiveBannerAdSizeWithWidth(CGFloat width) を使用します。このメソッドでは現在の向きで広告を読み込みます。

    インライン アダプティブ バナーの高さを制限する

    デフォルトでは、maxHeight 値を指定せずにインスタンス化されたインライン アダプティブ バナーの maxHeight はデバイスの高さと同じになります。インライン アダプティブ バナーの高さを制限するには、GADInlineAdaptiveBannerAdSizeWithWidthAndMaxHeight(CGFloat width, CGFloat maxHeight) メソッドを使用します。

    参考情報

    GitHub の例

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

    Swift Objective-C