consent-dialog-admob-android

Implement Consent Dialogue For Google Admob

In this article we are going to learn that how to integrate Admob Consent SDK  to make android app GDPR compliant. Make sure that this tutorial is only for AdMob publishers of Android Mobile Application. Before the proceed let’s see that what is GDPR. To know more about integrate admob consent SDK read the official page.

 

INTRODUCTION

 

1.What is GDPR ?

GDPR Stands for General Data Protection Regulation. GDPR is a regulation that requires businesses to protect the personal data and privacy of European Union (EU) citizens for transactions that occur within EU member states. And non-compliance could cost companies dearly.

Companies that collect data on citizens in European Union (EU) countries will need to comply with strict new rules around protecting customer data by May 25 2018, So we need to Integrate Admob Consent SDK and get user’s consent before requesting ads using Admob.

2. What changes are required for AdMob Publisher to comply with GDPR ?

GDPR is a broad protection measure for EU citizens with regards their rights on their personal data collected by online businesses. So before the used personal data of EU citizens get the consent from the user and allows to modify or delete the consent. In our case [AdMob publishers] need to take external permission from EU users before displaying the ads.

To take the user permission or consent from the user need to implement Google’s Consent SDK. Now implement following steps to make your app GDPR compliance.

 

INTEGRATE ADMOB CONSENT SDK

 

3 Import Consent SDK

First of all make following changes in project/build.gradle. Add maven dependency that points to Google repository.

Now Open the app/build.gradle and add following dependency for Consent SDK.

NOTE : Make sure that this tutorial is only for without mediation ads integration apps, Google is currently unable to obtain and handle consents for mediation network.

4. Change Settings Of Admob.

Open Google AdMob dashboard and select Blocking Control -> EU user consent. Select custom set of ad technology providers and select preferred technology providers from the list.

NOTE : Make sure that Google’s Consent form is only support with custom Set Of Providers and providers list is less then or equal to 12. So select the ad technology providers less the 12. For the commonly used set of ad technology providers you need to implement custom consent dialogue to get consent.

 

Setup AdMob Dashboard To Integrate Consent SDK
Setup Netowrk Providers

5. Update Consent Status.

Now from your apps launch screen update the consent status. You need to update the consent status every time when user open the application. Add following lines of code into your MainActivity.java.

ConsentStatus will return three types of status.

  • PERSONALIZED The user granted consent for personalized ads.
  • NON_PERSONALIZED The user granted consent for non-personalized ads.
  • UNKNOWN The user neither granted nor declined consent for personalized or non-personalized ads.

5. Display Consent Form [Google’s Default ]

Now if Consent Status is UNKNOWN that means currently user consent is not setup so we need to display Consent form from the onCensentInfoUpdated methods. Add following lines of code to display Consent Form provided by Consent SDK.

Using above code your application will display Consent Form when user open the application. Make sure that consent form is only open if user is residence of EEA. Consent form is looks like.

Dialogue Displayed After Integrate Admob Consent SDK
Consent Dialogue

6. Forward Consent To Google Mobile Ads SDK.

Now before the loading the ads check the Consent Status and display ads as per users choice. Add the following lines of code to load ads and build AdRequest.

Pass nap = 1 only if user has selected NON_PERSONALIZED ads becuase by defualt google has provide PERSONALIZED ads to every user.

7. Testing.

The Consent SDK has different behaviors depending on the value of ConsentInformation.getInstance(context).isRequestLocationInEeaOrUnknown(). For example, the consent form fails to load if the user is not located in the EEA. To display Consent dialogue for testing you need to add following line of code when request for consent information update.

8. Reset Consent.

As GDPR guidelines before used personal data of EU citizens get the consent from the user and allows to modify or delete the consent. So we need to add option on apps setting to modify or reset the consent. Add following lines of code to reset the consent.

9 Conclusion.

Implement this code and write us if you have any issue. Make sure that this is the only support who has not implemented any mediation network and used custom sets of ads provider. You can also check how to implement custom consent dialogue for commonly used set of ad technology providers. For more information you can refer Admob Official page to integrate admob consent SDK.

Happy Coding 🙂