Obtaining Consent with the User Messaging Platform
Important: You must have a Funding Choices account linked to your AdMob account.
To create a Funding Choices account, go to Privacy & messaging in the AdMob UI and select Go to Funding Choices. The Funding Choices account is then created automatically in the background.
Before attempting to integrate the SDK you should ensure Funding Choices is enabled on your application and that you have created at least one form.
To support publishers in meeting their duties under this policy, Google offers the User Messaging Platform (UMP) SDK, which replaces the previous open source Consent SDK. The UMP SDK has been updated to support the latest IAB standards. We've also simplified the process of setting up consent forms and listing ad providers. All of these configurations can now conveniently be handled in the Funding Choices UI.
It is a best practice to load a form every time the user launches your app, even if you determine consent is not required, so that the form is ready to display in case the user wishes to change their consent setting.
This guide walks you through how to install the SDK, implement the IAB solutions, and enable testing features.
Request Consent Information
You retrieve the consent information through the
ConsentInformation instance accessible via:
This object has the consent information including:
consentInformation.getConsentStatus(): The current user consent status (see
consentInformation.getConsentType(): The type of consent (see
consentInformation.isConsentFormAvailable(): Whether a form is available to be loaded and displayed to the user;
It is recommended that you request an update of the consent information at every app launch. This will determine whether or not your user needs to provide consent.
To update consent information call the
requestConsentInfoUpdate() function on the consent information object.
This will dispatch one of two possible events:
ConsentInformationEvent.CONSENT_INFO_UPDATE_SUCCESS: When the consent information was updated successfully;
ConsentInformationEvent.CONSENT_INFO_UPDATE_FAILURE: When there was an error updating the consent information;
Load a form if available
Once you've determined that you will ask a user for consent, the next step is to determine if a form is available.
There are a variety of reasons why a form may not be available, such as:
- The user has limited ad tracking enabled.
- You tagged the user as under the age of consent.
To check if a form is available, use the
isConsentFormAvailable() method on the
To load the form call the
loadConsentForm() of the
This will dispatch one of two possible events:
UserMessagingPlatformEvent.CONSENT_FORM_LOAD_SUCCESS: When the form has been loaded and is ready to be shown;
UserMessagingPlatformEvent.CONSENT_FORM_LOAD_FAILURE: When an error occurred, try again later to load the form successfully before attempting to show;
Present the form if required
To present the form use the
showConsentForm() on the
You should determine if the user requires consent prior to presenting the form. To check if consent is required, check the
getConsentStatus() method on the
ConsentInformation object, which returns an value from the
ConsentStatus class. There are four possible values:
ConsentStatus.UNKNOWN: Unknown consent status.
ConsentStatus.REQUIRED: User consent required but not yet obtained.
ConsentStatus.NOT_REQUIRED: User consent not required. For example, the user is not in the EEA or the UK.
ConsentStatus.OBTAINED: User consent obtained. Personalization not defined.
You can also use the form to give your user the option to change their consent status. You may wish to do this in a settings screen, and call the
showConsentForm() to present the form so the user can change their consent as required.
showConsentForm() process will dispatch the
ConsentInformationEvent.CONSENT_FORM_DISMISSED event when the consent form was dismissed.
Force a geography
The UMP SDK provides a simple way to test your app's behavior as though the device was located in the EEA or UK using the
You will need to provide your test device's hashed ID in your app's debug settings to use the debug functionality. If you call
requestConsentUpdate() without setting this value, your app will log the required ID hash when run to the native device log.
To force the SDK to treat the device as though it is not in the EEA or UK, use
Note that debug settings only work on test devices. Emulators do not need to be added to the device id list as they have testing enabled by default.
In testing your app with the UMP SDK, you may find it helpful to reset the state of the consent SDK so that you can simulate a user's first install experience. The SDK provides the
reset() method of the
ConsentInformation interface to do this.
You should also call reset if you decide to remove the UMP SDK completely from your project.
Delay app measurement (optional)
By default, the Google Mobile Ads SDK initializes app measurement and begins sending user-level event data to Google immediately when the app starts. This initialization behavior ensures you can enable AdMob user metrics without making additional code changes.
However, if your app requires user consent before these events can be sent, you can delay app measurement until you explicitly initialize the Mobile Ads SDK or load an ad.
To delay app measurement, add the following
<meta-data> tag in your manifest additions, inside the
To delay app measurement, add the
GADDelayAppMeasurementInit key with a boolean value of
true to your app’s InfoAdditions: