Table of Contents
Integrating ads using Google AdMob
GDevelop supports integrating ads into your game using Google AdMob, on Android and iOS.
Ads can be loaded and displayed in your game at any time. They can be displayed as banners at the top or bottom of the screen, or displayed as interstitial screens. Interstitial screens are ads that cover the entire screen. Reward videos can also be displayed.
Banner ads are usually displayed during gameplay. Interstitial screens and reward videos are displayed after the completion of a level or an objective.
Setting up your Google AdMob account
To get started, go to AdMob website and create an account. Once that is done, you can create a new app and an ad unit.
Click on ''Apps“ then “Add App” in the left menu”.
Add your application by entering its name and choosing its platform. If your game is for both iOS and Android, you must register two ad units.
When created, your app id will be displayed.
Next, choose if the ad unit will be a banner, an interstitial screen or a reward video.
Enter the name for this ad unit and click on “Create Ad Unit”.
You will now see the app id and the ad unit identifier.
Setup Payments in Admob
Before your ads can be displayed, you need to set up the payment method in your account. Go to the Payments page and fill in the necessary information:
When your account is ready, Admob will tell you so by showing that your account is approved:
Ads should now be able to be shown.
Setting up your game
Once you have created your AdMob account and have the app id and the ad unit identifier, open your game properties. Open the Project Manager, then click on Game settings and Properties.
In the AdMob section, enter your app id, one for Android and one for iOS (though it might be the same).
Loading and displaying ads
Once your game is set up with the app id, you can add an event with an action to show the ad unit that you've created. All actions can be found inside the AdMob category:
Choose the actions adapted to your ad unit:
- If you created a banner, use the action to 1) Configure the banner and 2) Show the banner.
- For interstitials and rewarded videos, use the action to first load them (during the gameplay) and then the action to show them whenever you're ready (the player just finished a level for example).
In the action, paste the ad unit id in the parameters (one for Android and one for iOS). Because parameters are string expressions, you must put the ad unit identifier between quotes.
To display the ad as soon as it is ready, activate the corresponding option. It's only for interstitials and rewarded videos. Banners are loaded and shown when loaded automatically using the Show banner action.
Finally, while your account is not yet approved it is possible to view the space that the ad will take by activating the “Test Mode”. This will present a fake banner, interstitial or rewarded video - this is a great way to test your actions.
For this, insert the action to enable the test mode at the beginning of your game:
Testing and publishing your game on Android (or iOS)
You must first build your game for Android (or iOS) to have the ads displayed on your device. See the page about Android and iOS publishing.
The one-click packaging for Android service included with GDevelop is compatible with Admob, so no additional tooling or development kits are needed.
In summary, before you launch your application with ads, you must:
- Your Admob account needs to be approved.
- Make sure to disable the test mode.
- Double check that you have set the app id (for Android and iOS), and the ad unit identifiers (for Android and iOS).
Wait a few hours before seeing the first ads.
Example
See how the ads work in a game by opening the example called AdMob. Replace the app id and the ad unit identifiers in the actions to test with your own account.