Hi, I’m iki and I’m going to show you how to integrate Admob in Godot.
But first… Admob is a library that will allow you to show advertisement on your mobile games.
First, we need to create a project on Godot.
I’m going to create a new main scene, where i will show my ads.
I’m going to make this happen when the user press a button, so we need that element.
To begin with, we need to install a plugin, which will allow us to use the Admob functions.
In my case I have Godot 3.4, so I will choose the plugin version 3.4
I download the plugin
First of all, I need to save the scene for my new project.
Now we are going to enable the plugin from the settings menu.
If everything went well it will appear at the top.
Some options allow us to determine the age of our users, as Google is quite strict about that.
The Europe Consent is a consent required by countries of the European Union. So if your game is to be played there, it will require a consent that will be shown to the player.
Then we have the different types of ads that we can use. They are all set for testing by default, but we will change it to official advertisements later.
In banner, we can configure size and position of our banner. Below we have the ID, which helps us to identify the ad. At the moment, as you can see, it already includes test ID for Android and IOs.
Interstitial ads are those that will be displayed on the screen and can be closed when finished.
Rewarded are those that when looking at them will notify us that the player receives a reward. For example, in Sim City if you see ads you get extra energy or pieces to build.
Rewarded Interstitial are those that will also grant a reward, but the user does not have the option to close them before they finish. This is because for example, there are 10 second videos, and perhaps we do not want the player to be able to close them early.
Keep in mind that the identities that we will use for Android are not the same as those for IOS.
We are going to give the final configurations to the plugin to make it functional. For that we go to his page.
The first thing it tells us is that we must install a template. In my case I will install the Android one, but there is a specific page for the IOS one as well.
I am going to select the template according to my version.
In order to insert the template, we must indicate in Godot Engine that we will use a custom template.
And now we have to install a new export template for Android.
This creates a new folder. We can see that it tells us where we should paste the downloaded template files.
The plugin would already be up and running. Luckily, it includes a testing scene, in which we can test the different ads if we wish.
Keep in mind that all this you can only check on Android or IOS. On the computer it will not show you the ads.
Now we are going to configure it with our Admob account, so we can put real ads in it and start monetizing.
To do this, we must be logged into our Google account and go to the Admob page. Keep in mind that this service is linked to Google Analytics and Google Adsense, and it works for free.
Now I’m going to create the application profile within admob.
In my case I’m going to include Android ads, but if you want to also include IOS ads, you would have to create one for each one.
Here you must select if the application is already uploaded to the store. As my application is already in the Play Store, I’m going to say yes, but the process will be similar if you say no.
If you said no, here you must enter the name of your package. We will see shortly where that is.
If you chose yes, what you have to do now is look for your application in the list.
As you can see, it detects the name of the package. That name is the same that I have in my Godot project when exporting for Android, around here.
The project will be under review.
In order for Google to find more truthfulness and trust, it asks us to upload a certain file to the game’s website.
This will allow Google to authenticate the project, which will bring confidence to advertisers.
To create such a file, I must first go to all applications.
There I select app-ads.txt and go to the instructions.
It gives us the ID, which I am going to copy and paste into a new text document.
Now I am going to save it with the name that the instructions indicate.
What we have to do now is upload it to the game’s website. That process will depend on your hosting. In my case I will do it from CPANEL, using FILE MANAGER.
Just in the root directory, I upload the file.
We have almost everything, but we need ads. Let’s create one.
We have different types of ads to choose from, as I explained earlier.
In my case, I want the user to be able to choose whether or not to watch a video to have a certain reward.
The only thing I need to configure here is the ad name and the reward. As the amount of the reward will not be coins in my case, but I will program from the game what it will be, then I dont need to assign a certain amount or a particular name to it.
You can customize the ad even more, but by default it comes in handy.
Once the ad is created, it will provide us with 2 pieces of information.
The first data will be the same for all the ads that we are going to create. It tells us the identity of our application in ADMOB.
The second piece of information is the identity of our ad.
The most vital thing now is to bring our application identity from ADMOB to Godot.
So we copy it, and we are going to edit the AndroidManifest.xml file
If you want you can use a text editor, I prefer to use Visual Studio Code.
At the bottom, where it says CUSTOM APPLICATION, there we can put our codes.
First I paste our ID, but it must be accompanied by other directives that we will extract from the plugin instructions.
As you can see, our ID was inside the block. We already link our account. Now we go for the original advertising.
As you can see, our ID was inside the block. We already link our account.
Returning to the instructions, we see that we need to activate the plugin.
There are other considerations that you should do in case that your game is for children for example. But in general terms this would be enough.
If you are compiling for IOS, the policies are quite strict when it comes to data collection. Therefore, unless you consent to «APP TRACKING TRANSPARENCY», I recommend that you switch to non-personalized ads in your account.
This is done by going to BLOCKING, and then EU consent.
Continuing with the IOS case, in the admob.gdip file you should delete the NSUserTrackingDescription line.
Now, ending that part of IOS, let’s go back to the tutorial.
To finish the configuration, we are going to put the original advertising that we created.
We simply paste the ad ID where it belongs.
We have everything ready, so from the example code I am going to create my own script.
Now I’m going to start erasing everything that doesn’t work for me. I will only use one button, so I will start by deleting the rest of the elements.
Nor will I show messages on the console, therefore I will delete this.
At READY we have the signal connection for each type of ad. As I will only use REWARDED, I will proceed to eliminate the rest.
We therefore have left when the REWARDED loads, when it closes and when the reward is granted.
Now we are going to connect a signal to our button, which will trigger the ad.
Every time I press the button, I will load the ad, and when it is loaded, I will show it.
So I’m going to delete almost all the remaining functions, except for the ones related to the REWARDED ad.
As I said, when it loads what I will do is show the ad.
Before there was a bug for which it did not load on time. For that, what I did is put a pause of 1.5 seconds, but in theory that bug has already been solved so it would not be necessary.
And now it would be left to you to determine according to your game, what will happen when it closes or what will happen when you watch the video and receive the reward. That will depend on each case.
I would show you how it looks the ads in a game but it would be against the rules to show those ads on video. Also note that when testing, it is advisable to use testing ID for your ads, which you can Google from the official Admob page. If you show real ads in your tests, you run the risk of being banned.
Download Godot Engine:
Admob Official Website:
Admob Godot Plugin (For Android & iOS):
https://github.com/Poing-Studios/godot-admob-android
Find my Game Develop Courses 👨🎓 & more information in our website: