0

In the admob documentation, it's written that:

An ad unit ID is a unique identifier given to the places in your app where ads are displayed. Create an ad unit for each activity your app will perform. If you have an app with two activities, for example, each displaying a banner, you need two ad units, each with its own ID. AdMob ad unit IDs have the form ca-app-pub-XXXXXXXXXXXXXXXX/NNNNNNNNNN.

With the example:

<string name="banner_ad_unit_id">ca-app-pub-3940256099942544/6300978111</string>

I have a few activities that will use banners ads. For each banner, I'll use a different string name for sure (i.e banner_ad1_unit_id, banner_ad2_unit_id...). My question is:

  • I guess I should change\invent the digits to be unique for each banner. Can I change all the digits of "3940256099942544/6300978111"? (without changing the beginning of "ca-app-pub-") or must I change only the digits of "6300978111" or specific ones?

I am asking because in some activities I may want to use 2 banners and in others I'll use only one.

Daniel
  • 2,355
  • 9
  • 23
  • 30
Maor Cohen
  • 936
  • 2
  • 18
  • 33

2 Answers2

2

I guess I should change\invent the digits to be unique for each banner.

Ad Unit IDs are unique identifiers created in the AdMob console. The basic process goes like this:

  1. Create an AdMob account.
  2. Register an app for either Android or iOS.
  3. Create one or more ad units for the formats you want to display (banners, in this case).

Each time you create an ad unit, AdMob will tell you the ID for it, so you can insert it into your code.

Changing someone else's unit by altering a few digits (or simply inventing a new string of numbers) will not work. The server won't recognize the ID, and won't serve you any ads.

For more information on how to register ad units, see this help center article.

RedBrogdon
  • 5,113
  • 2
  • 24
  • 31
1

You have to use the same

banner_unit_ad_id

in all the banner ads i,e ca-app-pub-3940256099942544/6300978111 will be the same for all the banner ads

Abhriya Roy
  • 1,338
  • 17
  • 23
  • ohh so I just should change the string name? it's confusing because they write "each(activity) with its own ID" and not own string name.. – Maor Cohen Jan 22 '17 at 13:38
  • This is not the right answer. You can't just change the name of a string resource id to something that doesn't necessarily exist and expect your code to compile. Moreover, the ad unit listed in the answer is a test ad unit, and will not serve live ads. – RedBrogdon Jan 23 '17 at 04:29
  • @ErezShmiel, my answer is correct. I specifically told you that the ad-id should be the same and that you shouldn't change it, to which you asked if you should only change the string name, and i said you can use different string names. I guess, I could make things clear to you. And I dont know how RedBrogdon, works on the adsense team but doesn't get the simple fact that it doesn't depend on the string name. – Abhriya Roy Jan 23 '17 at 13:09
  • And about the ad-id being that of a test ad, I guess that is what people use when they test their applications, and maybe that is why, @RedBrogdon, you guys have written it! Before telling that something is absolutely wrong, please do read it once carefully. – Abhriya Roy Jan 23 '17 at 15:25