Dynamic Ads
Show GDPR-compliant ads via Google AdMob on Android.
- Pranav Pandey
- Android | Library
- 05 Dec, 2022
- 10 Min read
The initial setup and later experiences of using Google AdMob on Android.
ToC
Table of Contents
Background
I am publishing apps on Google Play since 2013 and like any other person, always disliked the idea of implementing ads
into my own apps as I believed that it would ruin the user experience. Although it’s true in most cases, if done correctly it can help in generating some revenue from the non-paying users which eventually adds up to the motivation to keep working for them.
Four years later, in 2017, I started exploring this domain but that was not an easy ride as I expected and it took rigorous efforts to setup and keep things on track.
A world of bots
I already had a Google account which I was using to publish apps on Play Store and tried to sign up with it for AdMob as well. As expected for a beginner when working on Google technologies (just like their interviews), the account was rejected straight away with a message that an AdSense verification was rejected for this account, please check in the AdSense console.
I was wondering what’s AdSense doing here. Later, I realized that these services appear to be separate but somehow connected to each other. I dug deeper and found that I once applied for AdSense verification for my website but got rejected due to insufficient content and that was interfering with the AdMob account creation. There was no way to archive or remove that rejection from the account history, so I wrote several emails to the support team but either got automated or no response at all. I am an independent developer and handle most of the things by myself, due to this initial disappointment I decided to hold the idea for a while as I was up for some other more important stuff.
I am curious to know why a trillion-dollar company’s one of the major businesses (advertisement) is operated mostly by bots and one can get nightmares when trying to get connected with an actual person in case of any issues.
A rare encounter
In August 2017, I attended the first-ever App Excellence Summit in Bengaluru, India. This is the only tech-related event I have ever attended physically until now as an individual. Fortunately enough, they had a talk on AdMob and after that, I discussed my issue with the speaker. During that conversation, I got a hint about trying with some other Google account which I did later and beyond my expectations, the account got approved within a jiffy.
As you can see, these technology events can be beneficial as still everything is not available online. So, I encourage you all to attend such events if you have supporting circumstances.
Initially, I didn’t try with any other account because I refrain from creating multiple accounts for business-related stuff and always try to keep the source of truth minimum. Recently, I was able to close that older (rejected) account and now my AdMob and AdSense are connected with a single source as this blog is now approved via AdSense.
Caution
Please do not ever try to use another account if you were, unfortunately, suspended due to policy violations as it will be banned again.
Implementation
This Ad
world is a complex system and requires various policy compliance and going through lots of not-so-user-friendly documentation to execute things correctly. That was my first encounter and I tried to take baby steps to at least understand the flow first. It took me a course of 2-3 years to be able to understand most of the stuff but that eventually turned out to be the most appropriate path to take in my case.
I was somewhat relieved after being able to create the AdMob account successfully. Now, I was figuring out the ways of showing ads in my apps. Most of my apps at that time were Sony small app
that appear on top of any task within a resizable window. There was the least possibility of showing ads there without affecting the user experience, so I decided to keep them ad-free forever.
Rotation was my only major app during that period and had been going through a rough phase. I suspected that introducing ads at this critical juncture would make things even worse, so I waited for some time and tried to build a strategy for a better future.
I already had a future plan for Rotation, and it was about to see the light of day in early 2018. The ads were part of that reboot without compromising the user experience.
Banner
Somewhere around 2018, I was about to release the Beta version of my app Rotation rebuilt from scratch to make things even better. Although the stable version was months away from its release, I decided to try and test ads as well to prepare for the future. Banner ads are the most suitable ones if the user experience is the top priority and I decided to put one at the very bottom of the screen.
The whole user interface was built in such a way that it will shift the UI up only if an ad is available, otherwise, the whole screen will be used for the app interface. That approach helped in keeping the banner ad separate from the app components and I never received a single criticism related to them.
For about 2 years, I kept using this only form of an ad in my apps until it started generating considerable amount of requests.
GDPR
In 2019, GDPR privacy laws came into effect and there were lots of policy changes going on in the Ad
world as well. The code I had written a year ago was not supportive enough to handle this major change and cumbersome migration path. Google was also aware of that and they had a dedicated library
to detect the GDPR regions which I used to disable ads there and that cost a considerable amount of revenue.
I was in trouble again as until then I had three major apps available on Google Play serving ads in a similar way. Rather than updating all one by one, I decided to build a generalized path that would work as a plug-and-play system to handle these continuous changes in a better way.
Software development is a dynamic environment where we have to embrace change all the time but when you work with Google technologies inside the mobile world, brace yourself for the toughest migrations as well.
Dynamic Ads
In 2020, during the pandemic, the downloads of Rotation had seen a considerable amount of growth due to the lack of service centers for physically damaged devices. It turned out that the people were using it to fix the partially broken screen temporarily by forcing their devices to work in a particular orientation for important stuff like accepting calls. I am glad that out of nowhere, Rotation suddenly became a useful companion for people in the toughest times of this generation.
Until then, I already had a set of open-source dynamic libraries to make Android development better and this unexpected event gave me further reassurance to start working on a full-fledged library to display ads throughout the app with minimum effort.
I started developing a generalized interface in the form of dynamic-ads library with support for different ad types so that they could be placed within an activity
just like any other view
or component. It also had support for GDPR regions with the ability to show consent forms to the users if available. The whole architecture was designed in such a way that it would never make any ad request without doing proper checks based on the device and region. It had abstracted a lot of overhead from the app and all the major stuff related to ads now works silently in the background controlled by a separate module.
Initially, it had only Banner and Native ads followed by a complete overhaul recently in 2022 with support for all kinds of ad types (Interstitial, Rewarded, etc.) served by AdMob.
Although the development of the library took a lot of time while going back and forth through the documentation, after that I was able to implement it quickly in all of my three major apps and the results were more than satisfactory.
By default, it uses a
G
rating to cover most of the use cases and to avoid any policy violations due to the mature content but it is fully customizable as a whole or on a per-ad basis.
Native
Native ads are the best when we have to blend them well with the user interface but that’s not an easy task either. AdMob servers just provide data in the form of text (JSON) which a developer has to place on the screen according to the requirements. As I already had developed a dedicated library to build user interfaces, I decided to extend it further and designed a built-in generalized layout to show native ads. It is fully customizable and also has the ability to provide a different layout on demand.
During that period, I was also working on my next major app Barquode, which is a tool to create, capture and manage various matrix codes including QR codes. It has a preview activity
to show the code along with various sharing options and I decided to put a native ad at the top of the preview for the non-paying users which helped me in testing the library as well.
Native ads should be placed where the possibilities of generating eCPM are high.
Interstitial
These are the full-screen ads that navigate away from the app and reward most as a developer. We should always use them carefully as they are one of the major reasons for limited ad-serving enforcements or even account suspension if used incorrectly. Google recommends that these ads should be shown at a special event or at certain intervals but tracking them is still an overhead that needs to be maintained apart from the core app functionality.
I built a dedicated system to track various events within the library with the ability to trigger ads on demand if available for the user. This led to the introduction of interstitial ads into my apps recently, shown at certain intervals and special events like game completion.
Interstitial ads should be introduced after gaining a considerable amount of users and always use them carefully. They can be limited within the AdMob console to avoid any invalid traffic.
Others
There are even more ad types including Rewarded ads which a developer can use to unlock some features for a limited period as a reward after watching a video. Please visit the official quick-start guide for more info.
Good luck!
I hope this post will help you in implementing things better in your apps. When working with AdMob…luck, I mean a lot of luck is required to setup things correctly and keep them stable. From my experiences, I have learned some key points that I am following for my apps for the last 4 years:
- Do not show more than one ad type on a single screen.
- Do not request ads before opening the app or drawing the screen.
- Disable personalized ads if the app is targeted to children of age below 13.
- Always take consent from the user if required before requesting ads from the server.
- Configure Ad rating within the console and while making the ad request on the device according to your target audience.
- Introduce various ad types gradually rather than in one go to analyze the traffic properly.
- Be careful when working with interstitial ads and introduce them later at certain intervals or special events.
- Be careful when giving access to some other account as it may affect yours if it had any policy violations.
- Avoid sharing ad-supported versions with family members or try to add their advertising id as test devices in the AdMob console to suppress possible invalid traffic from them.
- Always try to be compliant with both the policies, the AdMob and the platform on which you are distributing your app like Google Play.
- Use mediation to serve ads from multiple sources and to keep things going in case of any issues like limited ad serving.