Which Google ID do I use for AdMob Ads?
Which Google ID do I use for AdMob Ads?
If you’re looking at using Google AdMobs to display advertisements in your Mobile Application and are confused as to which ID to use then you need to read this article. When you login to your AdMod account, there are a lot of ID’s that are displayed and you need to make sure you use the right one otherwise your mobile advertisements will not be displayed. So let take a look at which one you should be using.
PUBLISHER ID
On your AdMob dashboard you will see on the top right hand corner your Publisher ID. It starts with pub-xxxxxxx followed by a string of numbers. Just like this:
This publisher ID is NOT what you should be using in your code. This ID is like your account number and is unique just to the account.
ANALYTICS ID
If you click on Analyze in your AdMob account you will see the App Overview with an ID that starts with UA-xxxxxxx. Just like this:
This ID is also NOT what you should be using in your code. This is specifically used in conjunction with Google Analytics to track things like your audience’s behaviour and conversions.
AD UNIT ID
Now this is the actual ID that you need to use in your Mobile Application code. It starts with ca-app-pub-xxxxxxx. Just like this:
In order to get this ad ID you need create a new banner for your Mobile Application. We’ll show you how to do this. Firstly, you need to add a new app to your Monetize tab.
To do this click on the Monetize Tab and then click Monetize new app
If you’re still developing your Mobile Application and it’s not actually published live on Google Play or iTunes App Store then select Add your app manually
Type in the name of your App. This should be the same name as what you intend to call it on in the app store. Then enter which platform you intend to monetise (the options are Android, iOS and Windows Phone 8). Click Add App
You will be asked to configure analytics, (our preference is to always create a new tracking ID). Click Save.
Now you will need to select which type of ads to display. There are two types of ads. The most common one is banner which will be displayed as a banner (covers part of the screen) or a Interstitial (covers full size screen). So select the type of ad depending on what you are trying to achieve, keeping in mind that the Interstitial can become quite annoying for users. If you’re clicking on Banner ads, try to change the ad style to blend in with your mobile application design. For example, changing the background colour to match the canvas area of your app.
Give it a name, something that makes sense like the location of the ad in your app. Finally click Save.
You will now see your new Mobile Ad Banner with the AD ID. Use this!
EXAMPLE CODE FOR ANDROID SDK
Here’s an example code to display the AdMobs:
import com.google.ads.AdRequest;
import com.google.ads.AdView;
public class Ads {
static void loadAds(AdView ads){
/**
* beginning of admob testing code
*
* this code is for testing admob only,
* when you publish the app remove the following code
*/
AdRequest adRequest = new AdRequest();
// use this code below to test admob on emulator
//adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
// use this code below to test admob on android device
//adRequest.addTestDevice("DEVICE_ID");
//ads.loadAd(adRequest);
/**
* end of admob testing code
*/
/**
* code below is used to publish admob when the app launched.
* remove the comment tag below and delete block of code
* that used for testing admob.
*/
ads.loadAd(new AdRequest());
}
}
In the above code, you will notice that there is commented code to display Ads within the emulation or with a test device. Just uncomment one of these if you’re planning to perform testing.
You will also need to modify the String.xml file under the Values folder. You need to have the admob_id which is the Ad Unit ID starting with ca-app-pub