Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom ads on admob android studio based on keyword

I have searched online but had not luck so far in my research, I have set up admobs in my android app and now I only want relevant ads to show up based on keyword that I set. My app is based on toys, so I only want ads related to toys to show

 AdRequest adRequest = new AdRequest.Builder().build();
 adView.loadAd(adRequest);

Looking at this: Admob ad on custom Dialog

This person has used:

 AdRequest request = new AdRequest();
        Set<String> keywords = new HashSet<String>();
        keywords.add("game");
        request.setKeywords(keywords);

However, this does not work.

like image 743
Henry Avatar asked Jan 17 '16 16:01

Henry


People also ask

How do I customize AdMob ads?

​Click Create ad unit. Follow the instructions in the Google Developers Get Started guide (Android, iOS, Unity) to implement this ad unit in your app code to start showing ads. You will need your app ID and ad unit ID during implementation. This ad unit won't show ads until you've completed this step.

What are the ad formats provided by Google AdMob?

AdMob supports the following ad formats: banner, interstitial, rewarded, and native.

How much does Google AdMob pay per click?

CPM is around $1, or $1 per 1000 Ad impressions. Clicks I have seen as high as $0.25, but its going to vary on the Ad shown obviously.


3 Answers

I think you need this:

AdRequest request = new AdRequest.Builder() 
.addKeyword("game").build();
.adView.loadAd(request);

You can try with this, but here are some examples, maybe you find what you allso need:

1.Test ads

Set up test ads by passing your hashed Device ID to AdRequest.Builder.addTestDevice:

 AdRequest request = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)        // All emulators
.addTestDevice("AC98C820A50B4AD8A2106EDE96FB87D4")  // An example device ID
.build();

2.Location

Location targeting information may also be specified in the AdRequest:

AdRequest request = new AdRequest.Builder()
.setLocation(location)
.build();

3.Gender

If your app already knows a user's gender, it can provide that information in the ad request for targeting purposes. The information is also forwarded to ad network mediation adapters if mediation is enabled.

AdRequest request = new AdRequest.Builder()
.setGender(AdRequest.GENDER_FEMALE)
.build();

4.Birthday

If your app already knows a user's birthday, it can provide that information in the ad request for targeting purposes. This information is also forwarded to ad network mediation adapters if mediation is enabled.

AdRequest request = new AdRequest.Builder()
.setBirthday(new GregorianCalendar(1985, 1, 1).getTime())
.build();

5.Designed for Families setting

If you have opted your app in to Google Play's Designed for Families program and you show ads in your app, you need to ensure those ads comply with the Designed for Families program requirements and ad policies.

Ad requests can be tagged as designed for families by setting the is_designed_for_families parameter to true in the extras:

Bundle extras = new Bundle();
extras.putBoolean("is_designed_for_families", true);

AdRequest request = new AdRequest.Builder()
    .addNetworkExtrasBundle(AdMobAdapter.class, extras)
    .build();

6.Child-directed setting

For purposes of the Children's Online Privacy Protection Act (COPPA), there is a setting called "tag for child directed treatment".

As an app developer, you can indicate whether you want Google to treat your content as child-directed when you make an ad request. If you indicate that you want Google to treat your content as child-directed, we will take steps to disable IBA and remarketing ads on that ad request. The setting can be used with all versions of the Google Play services SDK, via AdRequest.Builder.tagForChildDirectedTreatment(boolean):

If you set tagForChildDirectedTreatment to true, you will indicate that your content should be treated as child-directed for purposes of COPPA. If you set tagForChildDirectedTreatment to false, you will indicate that your content should not be treated as child-directed for purposes of COPPA. If you do not set tagForChildDirectedTreatment, ad requests will include no indication of how you would like your content treated with respect to COPPA.

AdRequest request = new AdRequest.Builder() .tagForChildDirectedTreatment(true) .build();

By setting this tag, you certify that this notification is accurate and you are authorized to act on behalf of the owner of the app. You understand that abuse of this setting may result in termination of your Google account.

7.Keyword

Add a keyword for targeting purposes.

AdRequest request = new AdRequest.Builder() .addKeyword(someKeyword) .build();

Loading an ad with targeting

Once your request targeting information is set, call loadAd on the AdView with your AdRequest instance.

AdRequest request = new AdRequest.Builder()
.setLocation(location)
.setGender(AdRequest.GENDER_FEMALE)
.setBirthday(new GregorianCalendar(1985, 1, 1).getTime())
.tagForChildDirectedTreatment(true)
.addKeyword("game")
.build();
adView.loadAd(request);

Additional information can be found on this link.

like image 145
Stanojkovic Avatar answered Sep 18 '22 10:09

Stanojkovic


After doing some research, it does not look like keywords are supported.

There have been various questions over the years that all have the same answer:

The documentation for targeting ads does not include any information on using keywords.

You can add keywords to your AdRequest using addKeyword(String keyword) in AdRequest.Builder, which is documented here. An example call would be like below:

AdRequest adRequest = new AdRequest.Builder().addKeyword("game").build();
adView.loadAd(adRequest);

However, as stated above- it does not look like these keywords are being used on the backend.

The AdMob support site shows that there are three ways advertisers can choose to target their ads- context (keywords, presumably implicit rather than explicit), placement, and interest.

You can filter outside of your app by allowing and blocking ads, which if you truly do only want to show ads related to toys, then you will have to block everything except the toys category shown in the general category list.

like image 21
Sean O'Toole Avatar answered Sep 19 '22 10:09

Sean O'Toole


You can try doing this :

AdRequest.Builder builder = new AdRequest.Builder()
        .addKeyword("game");

Now you can build the adrequest.

like image 23
Damanpreet Singh Avatar answered Sep 17 '22 10:09

Damanpreet Singh