Get started

Under the Google EU User Consent Policy, you must make certain disclosures to your users in the European Economic Area (EEA) along with the UK and obtain their consent to use cookies or other local storage, where legally required, and to use personal data (such as AdID) to serve ads. This policy reflects the requirements of the EU ePrivacy Directive and the General Data Protection Regulation (GDPR).

To support publishers in meeting their duties under this policy, Google offers the User Messaging Platform (UMP) SDK. The UMP SDK has been updated to support the latest IAB standards. All of these configurations can now conveniently be handled in AdMob privacy & messaging.

Prerequisites

User message types

See User message types for a full list of supported messages. For specific instructions on implementing each message type, see the left navigation bar.

Determine if a message needs to be displayed

You should request an update of the user's consent information at every app launch, using RequestConsentInfoUpdate() before loading a form. This can determine whether or not your user needs to provide consent if they hadn't done so already or if their consent has expired.

Use the information stored in the ConsentInformation object when you present the form when required.

Here is an example of how to check the status on app start:

using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Ump;
using GoogleMobileAds.Ump.Api;

public class UmpManager : MonoBehaviour
{
    void Start()
    {
        // Set tag for under age of consent.
        // Here false means users are not under age.
        ConsentRequestParameters request = new ConsentRequestParameters
        {
            TagForUnderAgeOfConsent = false,
        };

        // Check the current consent information status.
        ConsentInformation.RequestConsentInfoUpdate(request,
                                                    OnConsentInfoUpdated);
    }

    void OnConsentInfoUpdated(FormError error)
    {
        if (error != null)
        {
            // Handle the error.
            UnityEngine.Debug.LogError(error);
            return;
        }
        // If the error is null, the consent information state was updated.
    }
}

Load a form if available

Before displaying a form, you first need to determine if one is available. Unavailable forms can be due to the user enabling limited ad tracking or if you’ve tagged them as under the age of consent.

To check the availability of a form, use the IsConsentFormAvailable() method on the ConsentInformation instance you created earlier.

Then, add a wrapper method to load the form:

void OnConsentInfoUpdated(FormError error)
{
    if (error != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(error);
       return;
    }
    // If the error is null, the consent information state was updated.
    // The consent information state was updated.
    // You are now ready to check if a form is available.
    if (ConsentInformation.IsConsentFormAvailable())
    {
        LoadConsentForm();
    }
}

void LoadConsentForm()
{
    // Loads a consent form.
}

To load the form, use the static LoadConsentForm() method on the ConsentForm class.

void LoadConsentForm()
{
    // Loads a consent form.
    ConsentForm.LoadConsentForm(OnLoadConsentForm);
}

void OnLoadConsentForm(FormError error)
{
    if (error != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(error);
        return;
    }

    // The consent form was loaded.
    // You are now ready to show the form.
}

Present the form if required

After you’ve determined the form's availability and loaded it, use the Show() method on the ConsentForm instance to present the form.

Use the ConsentInformation object from earlier to check the consent status and update your LoadConsentForm() method:

void LoadForm()
{
    // Loads a consent form.
    ConsentForm.LoadConsentForm(OnLoadConsentForm);
}

void OnLoadConsentForm()
{
    if (error != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(error);
        return;
    }

    // The consent form was loaded.
    // You are now ready to show the form.
    if(ConsentInformation.ConsentStatus == ConsentStatus.Required)
    {
        ConsentForm.Show(OnShowForm);
    }
}

void OnShowForm(FormError error)
{
    if (error != null)
    {
        // Handle the error.
        UnityEngine.Debug.LogError(error);
        return;
    }

    // Handle dismissal by reloading form.
    LoadForm();
}

If you need to perform any actions after the user has made a choice or dismissed the form, place that logic in the completion handler or callback for your form.

Testing

Force a geography

The UMP SDK provides a way to test your app's behavior as though the device was located in the EEA or UK using the DebugGeography field on ConsentDebugSettings.

You must provide your test device's hashed ID in your app's debug settings to use the debug functionality. If you call RequestConsentInfoUpdate() without setting this value, your app logs the required ID hash when run.

void Start()
{
    var debugSettings = new ConsentDebugSettings
    {
        // Geography appears as in EEA for debug devices.
        DebugGeography = DebugGeography.DEBUG_GEOGRAPHY_EEA,
        TestDeviceHashedIds = new List<string>
        {
            "TEST-DEVICE-HASHED-ID"
        }
    };

    // Set tag for under age of consent.
    // Here false means users are not under age.
    ConsentRequestParameters request = new ConsentRequestParameters
    {
        TagForUnderAgeOfConsent = false,
        ConsentDebugSettings = debugSettings,
    };

    // Check the current consent information status.
    ConsentInformation.RequestConsentInfoUpdate(request,
                                                OnConsentInfoUpdated);
}

With the DebugGeography enum, you have the option to force the geography to one of these options:

DebugGeography Description
DISABLED Debug geography disabled.
EEA Geography appears as in EEA for debug devices.
Not_EEA Geography appears as not in the EEA for debug devices.

Note that debug settings only work on test devices. Emulators don't need to be added to your device ID list as they already have testing enabled by default.

In testing your app with the UMP SDK, you might find it helpful to reset the state of the SDK so that you can simulate a user's first install experience. The SDK provides the Reset() method to do this.

ConsentInformation.Reset();

You should also call Reset() if you decide to remove the UMP SDK completely from your project.