Unity Ads をメディエーションと統合する

This guide shows you how to use the Google Mobile Ads SDK to load and display ads from Unity Ads using mediation, covering waterfall integrations. It covers how to add Unity Ads to an ad unit's mediation configuration, and how to integrate the Unity Ads SDK and adapter into a Flutter app.

Supported integrations and ad formats

The AdMob mediation adapter for Unity Ads has the following capabilities:

Integration
Bidding  1
Waterfall
Formats
Banner
Interstitial
Rewarded
1 Bidding integration is in closed beta, reach out to your account manager to request access.

Requirements

  • Latest Google Mobile Ads SDK
  • Flutter 3.7.0 or higher
  • To deploy on Android
    • Android API level 21 or higher
  • To deploy on iOS
    • iOS deployment target of 12.0 or higher
  • A working Flutter project configured with Google Mobile Ads SDK. See Get Started for details.
  • Complete the mediation Get started guide

Step 1: Set up configurations in Unity Ads UI

Unity 広告にお申し込みまたはログインしてください。

プロジェクトを作成する

Unity 広告ダッシュボードの [プロジェクト] をクリックし、[プロジェクトを作成] をクリックします。

フォームに入力し、[プロジェクトを作成] をクリックしてプロジェクトを追加します。

[収益化] >[開始] をクリックし、[開始] をクリックします。

[Project Setup](プロジェクトの設定)モーダルで [I plan to use Mediation](メディエーションを使用する)を選択し、[Google メディエーション パートナーの AdMob を選択し、[次へ] をクリックします。

広告設定を選択し、[次へ] をクリックします。

フォームに入力し、[プロジェクトを追加] をクリックします。

ゲーム ID をメモしておきます。

広告ユニットを作成する

[収益化] >[広告ユニット] で [広告ユニットを追加] をクリックします。

[広告ユニット名] を入力し、[プラットフォーム] と [広告フォーマット] を選択します。

Android

iOS

最後に、[作成] をクリックして広告ユニットを保存します。

プレースメントを追加

単価設定

入札プレースメントを作成するには、Google アカウント マネージャーにお問い合わせください。

プロジェクトが作成されたら、[収益化] >プレースメント。宛先 新しいプレースメントを作成するには、広告ユニットに [プレースメントを追加] をクリックします。

必要な情報を入力して [プレースメントを追加] をクリックします。

プレースメント ID をメモしておきます。

Android

iOS

Unity Ads Reporting API キーの場所を確認する

単価設定

入札の統合では不要です。

[ゲーム ID] と [プレースメント ID] に加えて、 Unity Ads の API キー組織コア ID を設定します。 AdMob 広告ユニット ID。

[収益化] >設定 >API 管理] に移動し、 Monetization Stats API アクセスキー

次に、[収益化] >[Organization Settings] に移動し、 Organization Core ID の値です。

テストモードをオンにする

テストモードは Unity 広告ダッシュボード。プロジェクトの [テスト] タブを選択します。

各アプリの編集ボタンをクリックすると、アプリを強制的にテストモードにできます。 [Override client test mode] をオンにして、 すべてのデバイスで強制的にテストモードをオン(テスト広告を使用)します

Android

iOS

または、 [Add Test Device] ボタン。

フォームに記入して [保存] をクリックします。

Step 2: Set up Unity Ads demand in AdMob UI

広告ユニットのメディエーション設定を行う

Android

手順については、 Android 向けガイドのステップ 2 をご覧ください。

iOS

手順については、 iOS 向けガイドのステップ 2 をご覧ください。

Add Unity Ads to GDPR and US state regulations ad partners list

GDPR 設定 米国の州規制の設定 の手順に沿って、 AdMob UI の GDPR および米国の州規制の広告パートナーのリストに Unity Ads を追加します。

Step 3: Import the Unity Ads SDK and adapter

pub.dev による統合

最新バージョンの SDK とともに次の依存関係を追加します。 Unity Ads パッケージ内の SDK とアダプタ pubspec.yaml ファイル:

dependencies:
  gma_mediation_unity: ^1.0.0

手動統合

最新バージョンの Google モバイル広告メディエーション プラグイン Unity Ads ダウンロードしたファイルを解凍し、抽出したプラグイン フォルダを追加します。 (およびその内容)を Flutter プロジェクトに追加します。次に、Terraform でプラグインを pubspec.yaml ファイルに次の依存関係を追加します。

dependencies:
  gma_mediation_unity:
    path: path/to/local/package

Step 4: Implement privacy settings on Unity Ads SDK

Under the Google EU User Consent Policy, you must ensure that certain disclosures are given to, and consents obtained from, users in the European Economic Area (EEA) regarding the use of device identifiers and personal data. This policy reflects the requirements of the EU ePrivacy Directive and the General Data Protection Regulation (GDPR). When seeking consent, you must identify each ad network in your mediation chain that may collect, receive, or use personal data and provide information about each network's use. Google currently is unable to pass the user's consent choice to such networks automatically.

The Google Mobile Ads mediation plugin for Unity Ads includes the GmaMediationUnity.setGDPRConsent() method. The following sample code shows how to pass consent information to the Unity Ads SDK. If you choose to call this method, it is recommended that you do so prior to requesting ads through the Google Mobile Ads SDK.

import 'package:gma_mediation_unity/gma_mediation_unity.dart';
// ...

GmaMediationUnity.setGDPRConsent(true);

See Unity Ads' Privacy Consent and data APIs and Complying with GDPR guides for more details and the values that can be provided in each method.

US states privacy laws

U.S. states privacy laws require giving users the right to opt out of the "sale" of their "personal information" (as the law defines those terms), with the opt-out offered via a prominent "Do Not Sell My Personal Information" link on the "selling" party's homepage. The U.S. states privacy laws compliance guide offers the ability to enable restricted data processing for Google ad serving, but Google is unable to apply this setting to each ad network in your mediation chain. Therefore, you must identify each ad network in your mediation chain that may participate in the sale of personal information and follow guidance from each of those networks to ensure compliance.

The Google Mobile Ads mediation plugin for Unity Ads includes the GmaMediationUnity.setCCPAConsent() method. The following sample code shows how to pass consent information to the Unity Ads SDK. If you choose to call this method, it is recommended that you do so prior to requesting ads through the Google Mobile Ads SDK.

import 'package:gma_mediation_unity/gma_mediation_unity.dart';
// ...

GmaMediationUnity.setCCPAConsent(true);

Step 5: Add required code

Android

No Additional code required for Unity Ads Android integrations.

iOS

SKAdNetwork integration

Follow Unity Ads' documentation to add the SKAdNetwork identifiers to your project's Info.plist file.

Step 6: Test your implementation

テスト広告を有効にする

AdMob にテストデバイスを登録し、 Unity Ads UI でテストモードを有効にします。

テスト広告を確認する

Unity Adsからテスト広告を受信していることを確認するには、広告インスペクタで Unity Ads (Waterfall) 広告ソースを使用して単独の広告ソースのテストを有効にします。

Error codes

If the adapter fails to receive an ad from Unity Ads, publishers can check the underlying error from the ad response using ResponseInfo under the following classes:

Android

com.google.ads.mediation.unity.UnityAdapter
com.google.ads.mediation.unity.UnityMediationAdapter

iOS

GADMAdapterUnity
GADMediationAdapterUnity

Here are the codes and accompanying messages thrown by the UnityAds adapter when an ad fails to load:

Android

Error code Reason
0-10 UnityAds SDK returned an error. See code for more details.
101 UnityAds server parameters configured in the Admob UI are missing/invalid.
102 UnityAds returned a placement with a NO_FILL state.
103 UnityAds returned a placement with a DISABLED state.
104 UnityAds tried to show an ad with a null context.
105 Context used to initialize, load and/or show ads from Unity Ads is not an Activity instance.
106 UnityAds tried to show an ad that's not ready to be shown.
107 UnityAds is not supported on the device.
108 UnityAds can only load 1 ad per placement at a time.
109 UnityAds finished with an ERROR state.
200-204 UnityAds Banner a specific error. See code for more details.

iOS

0-9 UnityAds SDK returned an error. See Unity's documentation for more details.
101 UnityAds server parameters configured in the Admob UI are missing/invalid.
102 Device not supported by UnityAds.
103 UnityAds finished presenting with error state kUnityAdsFinishStateError.
104 The Unity ad object is nil after calling its initializer.
105 Failed to show Unity Ads due to ad not ready.
106 UnityAds called a placement changed callback with placement state kUnityAdsPlacementStateNoFill.
107 UnityAds called a placement changed callback with placement state kUnityAdsPlacementStateDisabled.
108 An ad was already loaded for this placement. UnityAds SDK does not support loading multiple ads for the same placement.

Unity Ads Flutter Mediation Adapter Changelog

Version 1.0.0

  • Initial release.
  • Verified compatibility with Unity Android adapter version 4.10.0.0
  • Verified compatibility with Unity iOS adapter version 4.10.0.0