Ads - Google Mobile Advertising (v1.3+)

This page takes you through the setup procedure for Google Mobile Advertising support for the Android and iOS target modules.

Google Mobile Advertising

Signing up for Google Mobile Advertising is a simple procedure to start with, requiring that you sign up for a Google personal account (Google require this for all their services) if you haven't already got one. You will also be required to create an AdWords and AdSense accounts, but Google will take you through this process when you sign up.

Once you have signed up (or signed in), you are presented with the following page:


This introduction page gives you various options to get you started, and once you have set up your first ads it will show a dashboard with performance statistics, etc...


We recommend that your first port of call when signing up with Google Mobile Advertising is the Account section. Setting this up correctly is essential if you wish to receive any payment for your ads and only takes a moment. It also only needs to be done once so you may as well get it done sooner rather than later! Clicking on Accounts will take you to a page with an over-view of your account, and there you can change any of the personal details.

Once here, you should set up your account correctly by clicking on the Payments section to set that up otherwise you won't receive any money from your in-game ads. Make sure that you have the IBAN and SWIFT codes for your bank handy as they are required.

NOTE: Once this is done, Google will then deduct $1 from your account and then return it to you again in two separate operations. When these transactions have been finalized (it may take a week or two) you can start to withdraw any earnings you may have from ad revenue.

The only other section of any real interest to start with on this page is the section labelled Transaction History which gives you an overview of the current state of your Google Mobile Advertising account, with the amount earned and the current account balance being shown.

Adding an App

Clicking on the Monetise button will take you to a new screen where you are requested to supply a URL for the app (if it has been published) or add your app manually (Note: only iOS and Android are supported):


Once you have selected your app target (or given a URL), you will then be requested to choose either Banner or Interstitial ads. Each one will present a different set of options, but they both will request that you give your new ad a name, so make it something appropriate and easily identifiable.

Once that is done, you will be given the unique Add Unit ID for the ad you created, which you will need for integration with GameMaker later. You can click the "Done" button when finished, or continue and create another Ad Unit.



Once you have created your ad units, you can also configure them for Mediation. This simply means that Google will use other ads providers along with their own in-house ads, based on the details that you provide. To set up mediation, first go to the Monetise section, then click "All Apps", then the app you want to use mediation on, and finally you need to click the link marked "Edit Mediation".



The next screen will list all the providers that mediation is enabled for, and to add new providers, simply click the "New Ad Network" button. By default the Google Mobile Advertising network is selected, but this can be removed if you wish (as long as some other network is added too), and you can add in as many of the other networks as you wish, as long as you have signed on with them previously.

In this way you can integrate different ad networks into your app, even though GameMaker: Studio does not actually have their SDK integrated into the IDE or an Extension Package for them, and it also gives you the opportunity to use providers that may offer a higher value for click-throughs than Google Mobile Advertising currently do.

Each network has it's own configuration screen where you can set different properties and supply the app id codes that are required, and then once you are finished your app will display ads from any of them, based on the Google Mobile Advertising settings that you have chosen.


The final point of interest when dealing with Google Mobile Advertising, is the AdMob Network Report page that can be found underneath the Peformance Reports section of the "Monetize" page. This section of the Google Mobile Advertising network pages contains detailed information about your apps performance, and includes requests, eCPM, fill rate etc... so that you can track the performance of different apps and ad types over time.


With the 1.3 update of GameMaker: Studio, advertising has been taken out of the IDE and has been replaced by Extension Packages. You can get these from the YoYo Games Marketplace, or download them from the "Demos" tab of the GameMaker: Studio "Welcome" page when you start it. So, you should make sure you either have the extension package or have downloaded it from the demo feed before continuing (if you download the demo, it contains a help file which explains how to create the GMEZ extension package which you will need to continue).

NOTE: For the normal (ie: non YYC) Android target, you need to build a final APK to test your games or the demo project, as the test play function will not work.

Initialising Google Mobile Advertising

Once you have your Google Mobile Advertising GMEZ, you need to install it in your game, so you would right-click on the "Extensions" folder, and select "Import Extension", browsing to the place where you have the Google Mobile Advertising package saved. Once it has been added, you then need to set up your game to initialise the Google support by adding the following line of code:


This code should only be run once in your game, preferably in the game start event of the very first object. You need to supply an argument for the interstitial ad ID that you want to use. This ID values can be found by clicking the "Monetize" section, and then "All Apps", then the app you are interested in. You want to copy the Ad Unit ID shown below each of the enabled ads, and they should be added as strings, eg: "ca-app-pub-6491754804335121/5518589690". If you only use banner ads, then you can use an empty string "" for this function, and supply the banner ad ID string in the following section when you want to show the ad.

Showing Banner Ads

Once the above mentioned function has been added, showing the ads requires only a few lines of code, which should be placed in the appropriate object in your game.

For banner ads, you need to call:

GoogleMobileAds_AddBanner(BannerID, sizeType);

This will add a banner ad to your game. You can also place the ads when you create them using the function:

GoogleMobileAds_AddBannerAt(BannerID, sizeType, x, y)

The "sizeType" argument refers to the type of banner ad that your dashboard has been set up to show and is covered in the extension package by using the following constants:

  • GoogleMobileAds_Banner
  • GoogleMobileAds_MRect
  • GoogleMobileAds_Full_Banner
  • GoogleMobileAds_Leaderboard
  • GoogleMobileAds_Skyscraper

So, your final code for creating a banner will look something like this:

GoogleMobileAds_AddBannerAt("ca-app-pub-6491754804335121/5518589690", GoogleMobileAds_Banner, 0, 0);

When calling a banner ad, it will trigger the Social Asynchronous Event, where you can get information about the ad being shown (see below for more details).

Show Interstitial Ads

For interstitial ads, you must first load them before they can be shown, so you should use:


to load it (and have supplied a valid ad ID string in the "init" function given above), and then a few seconds later check to see if it has loaded before showing it, like this:

if GoogleMobileAds_InterstitialStatus() == "Ready"

So, you would have an instance that loads an ad in it's create event, then you could use an alarm with the above code to poll the result and only show the ad when it is loaded (for example).

It is recommended that you think very carefully about just where interstitial ads should be shown as they are generally far more intrusive than banner ads and as such may annoy some users of your app if used too much, or placed in inconvenient moments. An excellent place to use them (for example) is right at the start of the game, or just after your splash screen.

Social Asynchronous Event

When calling a banner or interstitial ad, it will trigger a Social Asynchronous Event, which you can then use to perform extra actions (like placing a banner ad in a different position). The event creates a special ds_map() and stores its ID in the constant async_load. You can then parse this map to get information about the ad being shown.

When calling any ad:

Key - “type
Values - “banner_load”, “interstitial_load

The ds_map will have the key “type” which will then hold (as a string) either “banner_load”, or “interstitial_load”.

If the type is “banner_load” then the following key/value pairs will be returned:

Key - “loaded
Value - 1 for success or 0 for failure (reals)

Key - “width” (width in display pixels)
Value - “height” (height in display pixels)

If the type is “banner_load” then the following key/value pair will be returned:

Key - “loaded
Value - 1 for success or 0 for failure (reals)

An example code of the asynchronous event would look something like this:

var ident = ds_map_find_value(async_load, "type" );
var loaded = ds_map_find_value(async_load, "loaded");
if ident == "banner_load"
if loaded
    var bw = ds_map_find_value(async_load, "width");
    var bh = ds_map_find_value(async_load, "height");
    var px = (display_get_width() - bw)/2;
    var py = (display_get_height() - bh)/2;
    GoogleMobileAds_MoveBanner(px, py);
else if ident == "interstitial_load"
global.interLoading = false;

Test Ads

To prevent unwanted click-through while testing your games (as this could cause Google to ban your account), you can enable Test Ads. to enable this you will need to add the Device ID into the appropriate function for the platform. This Device ID is shown in the Xcode or ADB debug output and you should make a copy of it.

NOTE: If you do not require test ads, this debug output can be ignored.


Further Information

For further information on the AdMob network of services please consult the following pages:

Have more questions? Submit a request


Article is closed for comments.