WARNING: The contents of this article have been merged into the GitHub wiki's Setup page. This article is no longer updated and its contents may be out of date. |
While Google is primarily directed towards supporting their Android platform, they do provide the AdMob platform to deliver advertising to both Android and iOS. In this article we will take you through the steps required to set up your game on the AdMob dashboard, as well as prepare it in GameMaker so that ads will be shown when the final game is played by users.
NOTE: If you have the Amazon Fire target, the setup for advertising is exactly the same as is described in this article for Android.
If you have not already signed up for an AdMob account, you should do this now (it's free), and also ensure that you have your game set up and running on the target platform(s). You can find setup guides from the following links:
We also recommend that you read the AdMob Implementation Guidelines, as these outline how Google expects you to use each type of ad unit:
Adding Your Game To The AdMob Dashboard
Once you have signed up and logged in to your AdMob account, you can start to add the games you want to monetise to the dashboard. When it comes to AdMob, each version of a game is considered an individual app, so if your project is for iOS and Android then you'll need to add it twice, once for each platform.
NOTE: From now on this article assumes you will be publishing to both Android and iOS, but if that is not the case, simply skip the steps associated with the platform you do not wish to target.
From the main dashboard menu on the left, select the Apps category:
Here is where you will add the games that you want to monetise and define the different properties for the advertising to be shown. To add a game to the dashboard, simply click the Add App button. You will be asked if your app is for Android or iOS.
You will then be asked if you have already published the game to the App Store or Google Play. If you have already published and have a live store page, you should select "Yes" and then search for the app and click the "Add" button on the right:
Once added, you will be shown the App ID (which we'll need later) and be prompted to make an Ad Unit for the game or skip that step. Don't forget, if you have a game on both Google Play and the App Store, you will need to add it twice in this way and set up individual ad units for each one, so you may want to skip setting up an ad unit just now and go ahead and add the other version of the published app. Once you're ready and have linked both stores, you can go ahead to the section below on Creating An Ad Unit.
If you haven't yet published the game publicly to either of the supported stores, you can simply click "No" and continue.
Click the Add button when ready and you'll be taken to the overview page where you'll be shown the App ID - which you should take note of as you'll need it later - along with options to Create Ad Unit or skip that step. You can add ad units at any time to an app after it has been created so if you are doing Android and iOS you may want to skip the ad unit part and instead add the other version of the game. When ready you can continue on to the section on Creating An Ad Unit.
Creating An Ad Unit
Once you have added the app(s) you can then start creating ad units. There is no limit to ad units that you can add for an application. and they don't all need to be active in the same app at the same time. You can create various units with different properties and then swap the unit IDs in the game project to change which one is used (this will require a new upload of the project to the relevant stores).
If you didn't click the Create Ad Unit button when you added the game to the AdMob dashboard, then you will need to create the ad unit from the dashboard itself. For that simply go to the app listing and click the game title link:
Regardless of how you get here, the next thing you'll see is the App Overview page where you'll get the basic information and reports about the apps monetisation performance. From here, if the game has no ad units added yet, you'll see a handy button "Add Ad Unit" (alternatively you can click the Ad Units option from the Dashboard menu and add the unit from there):
You will then be presented with the option to select the type of ad unit to create:
All three types are supported by GameMaker, so we'll quickly run through the setup of each in the following sections.
Note that after creating each of your ad units you will be presented with the App Id (which you should already have taken note of) and the ad Unit ID:
The Unit ID is the ID that will be required by GameMaker to show the ads, so take a copy of it after creating each unit for later.
IMPORTANT! Once an ad unit is set up, it may take a few hours (up to 24) for it to start serving ads, and during that time any test you do using GameMaker may show an error in the console. This means that you should wait some time between creating the ad unit and testing.
Banner Ads
Banner ads are just what they say - banners of text, images or video that can be displayed anywhere in the screen at any time. Setting them up is as simple as giving the unit a name and then clicking the Create Ad Unit button, although there are some advanced settings available too (see the Google Documentation for details):
Once you click the Create Ad Unit button, the unit will be created and you can note the Unit ID and then click either Done, if you don't wish to make any other ad units, or Create Another Ad Unit, if you do.
Interstitial Ads
An interstitial ad is a full screen advert that can be either text, images or video, and they are usually shown at natural breaks in the game, like when completing a level or dying, etc... Like banner ads, when you select this format you can simply give it an identifying name and then click the Create Ad Unit button, although there are some advanced settings available too (see the Google Documentation for details):
Once you click the Create Ad Unit button, the unit will be created and you can note the Unit ID and then click either Done, if you don't wish to make any other ad units, or Create Another Ad Unit, if you do.
Rewarded Ads
Rewarded video ad units enable users to watch videos to earn in-app rewards, such as coins, extra lives, or points. You can set different rewards for different ad units, and specify the reward values and items users will receive. Note that rewarded ads can only be video ads, with a maximum length of 60 seconds.
As with the other ad types, you need to give the unit a name and then you can set the award amount, and the name of the "currency" that you are awarding. This can be anything appropriate for your game, like gold, mana, etc... In general you need do nothing else and can click the Create Ad Unit button, although there are some advanced settings available too (see the Google Documentation for details):
Once you click the Create Ad Unit button, the unit will be created and you can note the Unit ID and then click either Done, if you don't wish to make any other ad units, or Create Another Ad Unit, if you do.
Setting Up GameMaker
Once you have set up the ad units for the game, you need to open up GameMaker and prepare the project to show the ads. For this we'll need to first install the Google AdMob extension, which you can get by going to the Marketplace and adding it to your account (here).
Once added to your account, open your library (from the Marketplace menu in GameMaker) and then search for "admob" for it to show up in the list of purchased assets and click the "Download" button.
Once downloaded you can click the Import button (to the left of the Download button) which will present you with the components of the extension.
To use the extension you need the "AdMob" group, and to read the documentation, you need the "Included Files" group:
You can optionally import the "AdMob Demo" if you want to test the provided demo. If you do, make sure to import "YoYo Extension Assets" as well.
Clicking the Import button will install it.
Once that's done you will also need to ensure that the Minimum SDK API Level is set to at least 16 in the Android Game Options, as that is the minimum required API level for the AdMob SDK to build, while the Target and Compile should be on the latest:
Initialising AdMob
Once you have installed the extension, you are almost ready to start coding the ads into your project. However before you start, make sure that you have the App ID and the various Ad Unit IDs as we'll need them for the code. If you didn't copy this when you created the app listing, you can easily find it by going to the AdMob dashboard and selecting the Apps menu option then View All Apps:
From the apps listings, you then simply have to click the App ID icon to copy the App ID to the clipboard:
If you are wanting to show interstitial ads, then you will also need your Ad Unit ID for the interstitial ad unit, which (if you haven't already got it copied somewhere) you can get by clicking on the app in the AdMob dashboard, and then going to Ad Units and clicking the Ad Unit ID button to copy it to the clipboard. If you do not want to use interstitial ads, then simply supply an empty string "" as the Unit ID.
If you have any other ads (banners, or rewarded) then you should take a moment to copy each of those Ad Unit IDs too, as you'll need them later.
Implementing AdMob
For instructions on implementing ads into your project, please read the documentation provided with the extension. This can be found in the Included Files menu, which will take you to the /datafiles directory containing the documentation: