Android Tutorial FirebaseAdMob and User Consent

Status
Not open for further replies.
Use instead: AdsHelper extends FirebaseAdMob2 / Google Mobile Ads v20.0+

More information: https://developers.google.com/admob/android/eu-consent
By default, AdMob serves personalized ads.
With the new GDPR law, publishers (you) need to request consent before the private data can be used to serve personalized ads to EU users.

The main steps are:

1. Check the current consent state, usually in the starter service.
2. If the consent state is unknown and the user is from the EU (or his location is unknown) then show the consent form.

SS-2018-05-23_15.56.06.png


This step must be done from an Activity.

3. Show non-personalized or personalized ads based on the consent state and location.

The limit on 12 providers was removed. Make sure to use FirebaseAdMob v1.55+.

Note that the Google consent form will only work if there are 12 or less ad technology providers. There are 200 by default so you need to change it in your AdMob console:
Blocking Controls - EU USER CONSENT tab:


SS-2018-05-23_16.09.16.png



Testing

In order to test the behavior you can can add your device as a test device and set whether the location should be treated as coming from the EU:
B4X:
consent.AddTestDevice("D4AC977CA12D122C4563730CC762C302") 'check the unfiltered logs for the device id after calling RequestInfoUpdate
consent.SetDebugGeography(True) 'True = EU, False = Non-EU

You can set the consent state yourself and it will be saved automatically by setting the ConsentState property. This can be useful for debugging and to allow the user to change the previously selected option.

Starter service code:

B4X:
Sub Service_Create
   consent.Initialize("consent")
   consent.AddTestDevice("D4AC977CA12D122C4563730CC762C302")
   consent.SetDebugGeography(True) 'comment for regular operation
   consent.RequestInfoUpdate(Array("pub-144444444"))
   Wait For consent_InfoUpdated (Success As Boolean)
   If Success = False Then
       Log($"Error getting consent state: ${LastException}"$)
   End If
   Log($"Consent state: ${consent.ConsentState}"$)
   Log("EU: " & consent.IsRequestLocationInEeaOrUnknown)
   Do While IsPaused(Main)
       Sleep(100)
   Loop
   CallSubDelayed(Main, "ConsentStateAvailable")
End Sub

Main activity code:

B4X:
'show the consent form if needed
Sub ConsentStateAvailable
   Dim consent As ConsentManager = Starter.consent
   If consent.ConsentState = consent.STATE_UNKNOWN And consent.IsRequestLocationInEeaOrUnknown Then
       'Set last parameter to False if you don't want to show the "pay for ad-free" option.
       'Change privacy policy URL.
       consent.ShowConsentForm("https://www.mysite.com/privacy.html", True, True, True)
       Wait For Consent_FormResult (Success As Boolean, UserPrefersAdFreeOption As Boolean)
       If Success Then
           Log($"Consent form result: ${consent.ConsentState}, AdFree: ${UserPrefersAdFreeOption}"$)
       Else
           Log($"Error: ${LastException}"$)
       End If
   End If
   LoadAd
End Sub

'load ads:
Sub LoadAd
   Dim builder As AdRequestBuilder
   builder.Initialize
   Dim consent As ConsentManager = Starter.consent
   If consent.IsRequestLocationInEeaOrUnknown Then
       If consent.ConsentState = consent.STATE_NON_PERSONALIZED Then
           builder.NonPersonalizedAds
       Else if consent.ConsentState = consent.STATE_UNKNOWN Then
           Return
       End If
   End If
   builder.AddTestDevice("D4AC977CA12D122C4563730CC762C302")
   adview1.LoadAdWithBuilder(builder)
End Sub

Ad free option

If the user selects this option then the ConsentState will be kept UNKNOWN and UserPrefersAdFreeOption will be true (nothing else happens).


Dependencies: FirebaseAdmob v1.50+ (https://www.b4x.com/android/forum/threads/updates-to-internal-libraries.59340/#post-590564)
 
Last edited:

Pendrush

Well-Known Member
Licensed User
Longtime User
Read first post again:
Note that the Google consent form will only work if there are 12 or less ad technology providers. There are 200 by default so you need to change it in your AdMob console:
Blocking Controls - EU USER CONSENT tab:
You need to change this in AdMob console as Erel described i post #1.
 
D

Deleted member 103

Guest
Read first post again:

You need to change this in AdMob console as Erel described i post #1.
I'm sorry, but I still do not understand it.
The question is: what should I do if I do not make any changes in the Admob console?

If I make this change in the Admob console, then I have to select the "technology providers" myself, right?
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
I'm sorry, but I still do not understand it.
The question is: what should I do if I do not make any changes in the Admob console?

If I make this change in the Admob console, then I have to select the "technology providers" myself, right?
If you don't make the change in the console, or you do make the change but then don't limit the technology providers to 12 or less then the consent process won't work - in which case you might as well not bother putting it in your app.

If you want to use the consent SDK for EU users, you have to select 12 or less technology providers.

- Colin.
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
3. what will happen to older apps not yet updated? ads will continue to displayed or ads will stop showing?
I haven't updated any of my apps for consent yet & haven't seen any drop-off in ads being shown in EU countries - so it appears that ads will continue to be displayed regardless.

- Colin.
 

johndb

Active Member
Licensed User
Longtime User
If you don't make the change in the console, or you do make the change but then don't limit the technology providers to 12 or less then the consent process won't work - in which case you might as well not bother putting it in your app.

If you want to use the consent SDK for EU users, you have to select 12 or less technology providers.

- Colin.
I have implemented this in my Apps and I agree that it works very well. The stumbling block, if you can call it that, is which providers to select. I have only selected a few of the well known providers at the moment but would like to receive some advice as to what providers would be preferable?

John
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
I have implemented this in my Apps and I agree that it works very well. The stumbling block, if you can call it that, is which providers to select. I have only selected a few of the well known providers at the moment but would like to receive some advice as to what providers would be preferable?

John
Yeah - I have the same issue. The only way that I can see to figure out which ones you should go with is per my earlier post here ->FirebaseAdMob and User Consent
 

tufanv

Expert
Licensed User
Longtime User
Ads are my main income stream so I have some doubts about this :
While my main users are from a non-eu country ( my own country ) , many of the users may be in "unknown" location so this consent thing may be presented to them.
1) if the location is not eu , will anything change
2) if the location is unknown , they will be treated as eu , so will the ad impression drop as we are not sure which providers must be selected ?
3)what if I dont implement it at all .
4) most important questio nis , descreasing the providers to 12 from 200 will make the app revenue garbage. am i wrong ?
5) If i do not publish my apps for eu users , do i still need to implement this ?

these are the questions bothering me..
 
Last edited:

tufanv

Expert
Licensed User
Longtime User
A shorter question, if i unpublish my app from eu stores, do i need to do anything or am i good ?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
does descreasing the number of providers to 12 also effects the ads shown to non-eu people or it is still served by the all providers about 200 ?
If you decrease it in your AdMob settings then it will affect all users. Whether it will have an impact on your earnings or not that is a different question which I don't know the answer to.
 

tufanv

Expert
Licensed User
Longtime User
If you decrease it in your AdMob settings then it will affect all users. Whether it will have an impact on your earnings or not that is a different question which I don't know the answer to.
Then this is absurd. Why would anyone decrease the number of providers and decrease their income. Why can't they get this consent for all providers but just limited to 12. As always , google is throwing the ball to us and save their selves. I will wait some more weeks to implement this because this is non-sense, hope they can fix this somehow.
 

tufanv

Expert
Licensed User
Longtime User
and the worst thing is you can't do this app based , it is account based. EU user consent blocking controls applies to all apps in the account.
 

Pendrush

Well-Known Member
Licensed User
Longtime User
After few days of testing (Android and iOS app), I don't have drop in fill rate nor earning (50% of users, about 10.000, are on latest GDPR version of my app).
I have choose only Google as provider (you cannot disable Google). Also 85% of all users are from EEA.
If user is not from EEA he doesn't see consent dialog. I have also put another dialog with question: "Do you want to participate in Analytics and Crashlytics?" and write all data (written one by one) those two services get from users (IP address, location, age.. etc). Also users from EEA have option in menu to opt in/out as per GDPR you need to provide that option.
 
Last edited:

tufanv

Expert
Licensed User
Longtime User
After few days of testing (Android and iOS app), I don't have drop in fill rate nor earning (50% of users, about 10.000, are on latest GDPR version of my app).
I have choose only Google as provider (you cannot disable Google). Also 85% of all users are from EEA.
If user is not from EEA he doesn't see consent dialog. I have also put another dialog with question: "Do you want to participate in Analytics and Crashlytics?" and write all data (written one by one) those two services get from users (ID address, location, age.. etc). Also users from EEA have option in menu to opt in/out as per GDPR you need to provide that option.
so, according to your experience , selecting only admob does not effect the fill rate or earnings ? This is a good news. Also I have a question in my mind. Lets say I have only 1 app available to eu users and other 19 apps are not published in eu countries. So I f i change to custom providers all 20 apps are effected. Isnt there an app based blocking control ?
 
Status
Not open for further replies.
Top