Ads in Unity games

Ads in Unity games Tags: Dev tools
on

Advertisement is very popular type of game monetization. We can find games containing advertisements on web, in stores like Google Play or App Store as well as in all messaging and other types of ads. Every platform mostly contain different type of ads which may be often confusing for developers releasing cross-platform games. Implementation of ads due to advertisements-specific seems be often chaotic without any previous experience and achieving the best monetization results may require next additional steps like proerly selected place and frequency of ads and technical matters as header-bidding.

The good message is that today's solutions make it far simpler than ever before. This article describes advertisements implementation by using GameArter. GameArter is a cross-platform solution simplifying life to game developers. GameArter SDK is way to learn and use 1 single SDK for more platforms. While developer communicates still with 1 SDK, gamearter SDK translates his requests to automatically detected active platform and do exactly what a developer require. As a bonus, SDK allow cross-platform playing by synchronized data between user's accounts (Google play, aspp store, web...). Related features, game always use features and UI of targeted platform so the developer benefit from full connection with the platform.

Supported ads by GameArter

  • Web based ads (fullscreen ads for web)
  • AdMob ads (fullscreen, banner and rewarded ads for Android and iOS)
  • Unity Ads (in progress)

Route to achieve the highest possible CPM (cost per millie)

Regardless platform your game or app is on, there is usually selection of more ad solutions and ad providers to use. Differences between them do not need to be visible at a first sight, moreover the selection can be very confusing due to everyone's efforts to get his ads to your app and earn on it. From this reason, there is only 1 right way - header bidding and time-dynamic comparison of ad solutions and ad providers.

Header bidding is an advanced programmatic advertising technique when an ad space is offered to numerous SSPs and Ad Exchanges at once which then fight about filling the ad space by own ad content via an auction. An ad with highest price per display for content owner wins and is displayed.

By AdMob, header bidding can be achieved via mediation network. For a clear conscience of a well-functioning service, there is good to run also different ad services in the same time (e.g. Google AdMob and Unity Ads) and compare these results in certain frequency for mutual performance which define ratio inside which ads of individual ad services are displayed. This is applied similarly to every platform.

Cross-platform ads implementation to Unity

By cross-platform in the title, we have in mind a complex of ad types, ad solutions, networks and ad providers for every specific platform which are automatically selected, initialized and activated via GameArter on background, while from the perspective of game developer, he still uses 1 ad feature.

1. Ad units definition

GameArter Ad manager need to have inventory of all ad units in the game and app which should set, initialize track and optimize. This inventory is defined via in-game GameArter SDK and its prefab "GameArter_Initialize". This space allow to define ad units on basis of app needs (any number).

Ad units setup in Unity

Regardless target platform where the app or game will be released, there is always need to fill Ad Unit Id and select Ad Type.
Ad Unit Id: any string. This is unique ad unit definition by which you define ad unit to be displayed in an ad request. Ad Type: Type of the unit. If selected ad type is not available at the target platform, ad call will be ignored and app will freely continue in running. Availability of ad types is in following table:

Fullscreen / Interstitial ad

Web, Google Play, iOS

Fullscreen usually skippable ad.

Rewarded ad

Google Play, iOS

Fullscreen non-skippable ad.

Banner ad

Google Play, iOS

Ad in any space of any size

Native ad

Google Play

In progress.

Study SDK documentation for more game-behaviour requirements during ads!

2. Requesting ads

Requesting ads is possible by following request:


// Fullscreen / Rewarded / Native ads
Garter.I.RequestAd("adUnitId", (adstate) => { Debug.Log("ad callback: "+adstate ) )

// Banner ads
Garter.I.RequestAd("adUnitId", adAction (display/hide), adPosition, adSize, (adstate) => { Debug.Log("ad callback: "+adstate ) )

More information about interaction with ads in SDK documentation for Unity.

3. Required libraries for displaying ads

Web browser: No action needed. All libraries are implemented in web game player.

Google Play / iOS: GameArter currently support AdMob ads only. These ads require library called GoogleMobileAds. This library can be downloaded directly from original github or from GameArter SDK page. Once downloaded, import the library to unity project. Inside the library you may find also Unity Play Services Resolver library. If so, import this library allowing access to Android specific libraries together with the AdMob plugin. Once both imported, go to "Assets/Play Services Resolver/Android Resolver/Force Resolve". After this action, there will be loaded all required plugins to your project.

4. Additional required ads configuration

Web browser: No action needed. All configuration will be set automatically.

Android
Here it's a bit complicated. GameArter allow to display ads on Google Play by 2 ways:

  1. Running own ads - Require own AdMob account with created application and known appId. In this case, developer must also create own banners and insert their IDs to ads inventory defined in point 1. Due to no option to pay GameArter service as a share from revenue here, developer here pays gameArter on basis of usage of its services (number of requests and transferred data - standard pay as you use model)
  2. Running GameArter ads - App Id is provided by GameArter (via GameArter panel). Chanels for defined ad units in inventory are generated automatically here. In this case, GameArter services are paid by a share from revenue income.
Known appId must be added to 2 places:
  1. Ads inventory to GameArter ads manager. (GameArter_Initialize prefab (see point 1) - column Platform App Id / Android App Id).
  2. Into AndroidManifest.xml. AndroidManifest.xml file was created after "Resolve request" from point 3 and is available in location "Assets\Plugins\Android\GoogleMobileAdsPlugin/". Open that file and modify it by replacing default value "YOUR_ADMOB_APP_ID" on line 18 with your ad app id there. Save the file and close.

5. Ads testing

Ads displayed in Unity Editor are represented by displayed black boxes reflocting ad size, ad position and ad callbacks (loaded, closed, unsupported...). For displaying real ads on a target device, there is need of additional step - building the app. In a case of mobile ads, you can check ads already after build, no need to upload the app on google play. In a case of web browser version, there is need to upload the games to gamearter for displaying ads, however, here it's not usually needed, because there is nothing why the ads should not work.

Till the game is not published, there are displayed test ads. It is from a reason that there is strictly prohibited to display real ads for testing purposes.

6. Reports

Once game is released, GameArter track and display all reports on GameArter panel. Where possible, there is possible to check results as total as well as on basis of individual ad units.