Implementing AdMob ads targeting
An application can know diversity in a user's gender, age, locations, and more. Targeting your users based on many factors can significantly improve our user experience within our application. In this recipe, we're going to see how we can add just that to our Android and iOS applications.
Getting ready
Please follow the instructions mentioned previously on how to download/configure your project with Firebase AdMob on your respective platform.
How to do it...
Let us first see how ad targeting is implemented in Android:
- The idea is to add the new filtering metadata to the
AdRequest
builder object and use methods such assetGender()
for gender specification,getLocation()
for specifying the location, and more. - Such configuration is applied in every case and scenario. Despite your Ad type, the idea is similar, so for simple implementation, the code will look like the following:
AdRequest request = new AdRequest.Builder() .setGender(AdRequest.GENDER_MALE...