[GDPR & Unity] How to check my ConsentDebugSettings and Consent right?

1,350 views
Skip to first unread message

HamsterSY

unread,
Nov 15, 2023, 2:01:36 AM11/15/23
to Google Mobile Ads SDK Developers
Hi
I try to show consent and write my code by this tutorial:
https://developers.google.com/admob/unity/privacy


Unity version: 2019.4.32f1
GoogleMobileAds version 8.2.0


Heres my code:

            Debug.Log("[AdManager] Reset。");
            ConsentInformation.Reset();
            var debugSetting = new ConsentDebugSettings
            {
                DebugGeography = DebugGeography.EEA,
                TestDeviceHashedIds = new List<string>
                {
                    "My-device-id",
                }
            };
            //  Set tag for under age of consent.
            //  Here false menus users are not under age of consent.
            ConsentRequestParameters requestSetting = new ConsentRequestParameters
            {
                TagForUnderAgeOfConsent = false,
                ConsentDebugSettings = debugSetting,
            };
            //  Check the current consent information status.
            ConsentInformation.Update(requestSetting, (FormError consentError) =>
            {
                Debug.Log("[AdManager] update done");
                if (consentError != null)
                {
                    //  Handle the error.
                    Debug.LogError("[AdManager] update error.\n" + consentError);
                    return;
                }
               
                if (ConsentInformation.IsConsentFormAvailable())
                {
                    Debug.Log("[AdManager] consent available.");
                    LoadConsentform();
                } else
                {
                    Debug.Log("[AdManager] consent not available.");
                }
            });
            void LoadConsentform()
            {
                // Loads a consent form.
                ConsentForm.Load((ConsentForm consentForm, FormError formError) => {
                    if (formError != null)
                    {
                        //  Handle the error.
                        Debug.LogError("[AdManager] load error.\n" + formError);
                        return;
                    }
                    if (ConsentInformation.ConsentStatus == ConsentStatus.Required)
                    {
                        consentForm.Show((FormError showError) => {
                            if (showError != null)
                            {
                                Debug.LogError("[AdManager] show error.\n" + showError);
                                Debug.LogError("[AdManager]\n" + showError == null);
                                return;
                            }
                            //   Do my stuff.
                        });
                    }
                });
            }


When i build and run on the NoxPlayer, the log just show consent not available.
QQ.png
I'm not sure is my ConsentDebugSettings not set success or Consent not set yet, but no idea how to check it.
It's some way can help or something i was missing?

Mobile Ads SDK Forum Advisor

unread,
Nov 15, 2023, 4:34:47 AM11/15/23
to ujham...@gmail.com, google-adm...@googlegroups.com

Hi HamsterSY, 

Thank you for getting back to us.

To collect user consent you will have to create the GDPR message in the AdMob UI, which is a prerequisite to collect the user consent. Kindly refer to this article for more information on How to create GDPR message.

This message is in relation to case "ref:!00D1U01174p.!5004Q02qCQpf:ref"

Thanks,
 
Google Logo Mobile Ads SDK Team

 

HamsterSY

unread,
Nov 15, 2023, 10:25:19 PM11/15/23
to Google Mobile Ads SDK Developers
Hi
I follow the reply do MobileAds.Initialize before use  ConsentInformation  and make sure my DebugGeography set to DebugGeography.EEA.
Then use  ConsentInformation.IsConsentFormAvailable() to check but here still return false.
mycode.png
Still have question about have some way to check my  ConsentRequestParameters are correct and work?

For some reason my project no want to update to latest version AdMob SDK.
Mobile Ads SDK Forum Advisor 在 2023年11月15日 星期三下午5:34:47 [UTC+8] 的信中寫道:

Mobile Ads SDK Forum Advisor

unread,
Nov 17, 2023, 12:54:08 AM11/17/23
to ujham...@gmail.com, google-adm...@googlegroups.com

Hi, 

Thank you for getting back to us.

Can you please paste the below code in your script and let us know whether you are facing any issue while loading the consent form and kindly share app ID for further investigation.
using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using GoogleMobileAds.Ump;

using GoogleMobileAds.Ump.Api;

 

public class GDPRScript : MonoBehaviour

{

    ConsentForm _consentForm;

    // Start is called before the first frame update

    void Start()

    {

        var debugSettings = new ConsentDebugSettings

        {

            // Geography appears as in EEA for debug devices.

            DebugGeography = DebugGeography.EEA,

            TestDeviceHashedIds = new List<string>

            {

                "TEST - DEVICE- ID"

            }

        };

 

        // Here false means users are not under age.

        ConsentRequestParameters request = new ConsentRequestParameters

        {

            TagForUnderAgeOfConsent = false,

            ConsentDebugSettings = debugSettings,

        };

 

        // Check the current consent information status.

        ConsentInformation.Update(request, OnConsentInfoUpdated);

    }

 

    void OnConsentInfoUpdated(FormError error)

    {

        if (error != null)

        {

            // Handle the error.

            UnityEngine.Debug.LogError(error);

            return;

        }

 

        if (ConsentInformation.IsConsentFormAvailable())

        {

            LoadConsentForm();

        }

        // If the error is null, the consent information state was updated.

        // You are now ready to check if a form is available.

    }

 

    void LoadConsentForm()

    {

        // Loads a consent form.

        ConsentForm.Load(OnLoadConsentForm);

    }

 

    void OnLoadConsentForm(ConsentForm consentForm, FormError error)

    {

        if (error != null)

        {

            // Handle the error.

            UnityEngine.Debug.LogError(error);

            return;

        }

 

        // The consent form was loaded.

        // Save the consent form for future requests.

        _consentForm = consentForm;

 

        // 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.

        LoadConsentForm();

    }

 

    // Update is called once per frame

    void Update()

    {

HamsterSY

unread,
Nov 17, 2023, 4:00:27 AM11/17/23
to Google Mobile Ads SDK Developers
Hi
I try the code from reply but still get false from ConsentInformation.IsConsentFormAvailable().
I have a new question, if the admob's  GDPR set to draft no publish that will effect the  ConsentInformation.IsConsentFormAvailable()?

Mobile Ads SDK Forum Advisor 在 2023年11月17日 星期五下午1:54:08 [UTC+8] 的信中寫道:

Mobile Ads SDK Forum Advisor

unread,
Nov 17, 2023, 4:20:45 AM11/17/23
to ujham...@gmail.com, google-adm...@googlegroups.com
Hi HamsterSY,

Kindly publish the consent form in Admob UI. Consent will not be shown if it is in draft.

HamsterSY

unread,
Nov 17, 2023, 5:37:12 AM11/17/23
to Google Mobile Ads SDK Developers
Hi
Got it, i will tell my teammate to  check this part.
Hope consent will show if GDPR are  publish ...
Anyway, i will report result when check GDPR are publish or in draft.
Thank you! 

Mobile Ads SDK Forum Advisor 在 2023年11月17日 星期五下午5:20:45 [UTC+8] 的信中寫道:

HamsterSY

unread,
Nov 20, 2023, 12:52:38 AM11/20/23
to Google Mobile Ads SDK Developers
Hi
My teammate check about Admob setting and sure about:
1. GDPR setting set to publish.
2. GDPR select app and add privacy policy URL.

But still no consent show on our game.

Is test app need upload to Google Play store to test?
I just build a apk version and play with Nox player.

Mobile Ads SDK Forum Advisor 在 2023年11月17日 星期五下午5:20:45 [UTC+8] 的信中寫道:
Hi HamsterSY,

Mobile Ads SDK Forum Advisor

unread,
Nov 20, 2023, 1:57:52 AM11/20/23
to ujham...@gmail.com, google-adm...@googlegroups.com
Hi,

Thank you for getting back to us.

To display the test consent form in your application, no need to upload it to the App Store.

Kindly provide the below information for further investigation:
  • app ID 
  • ad unit ID
  • Sample project reproducing the issue
If the file(s) you are looking to share are less than 25mb in total you can attach them to this case on your next reply. If you are having trouble attaching your file to this case or if your file(s) are larger than 25mb, kindly provide requested information to us via reply privately to author option or using the steps below:

1. Navigate to
https://docs.google.com/forms/d/e/1FAIpQLSfkAiXMeYP-fw1W3Z-tT9uwmATEKO5X6S-th0gR2ezdKaaqfg/viewform?usp=pp_url&entry.400550049=Mobile+Ads+SDK&entry.460850823=5004Q00002qCQpfQAG&entry.80707362=00210760
2. Fill out all fields, and attach your file(s).
3. Please reply back to this thread when you have uploaded your file(s). Please do not share this link.

HamsterSY

unread,
Nov 20, 2023, 6:25:23 AM11/20/23
to Google Mobile Ads SDK Developers
Hi
Thanks your reply and patience, but i still want find problem.

I have something question:

1.To test GDPR consent, i need to set test ad id?
https://developers.google.com/admob/unity/rewarded

2.I review my code, is need do MobileAds.Initialize before use ConsentInformation.Update?
https://developers.google.com/admob/unity/privacy

3.It's need call ConsentInformation.Update before every time before ad showing?

Mobile Ads SDK Forum Advisor 在 2023年11月20日 星期一下午2:57:52 [UTC+8] 的信中寫道:

Mobile Ads SDK Forum Advisor

unread,
Nov 20, 2023, 6:58:56 AM11/20/23
to ujham...@gmail.com, google-adm...@googlegroups.com

Hi HamsterSY,

Thank you for getting back to us.

I will check with our team regarding your query and one of my team members will reach out to you once we have an update on this. Meanwhile, your patience is highly appreciated. 

Mobile Ads SDK Forum Advisor

unread,
Nov 21, 2023, 11:24:24 AM11/21/23
to ujham...@gmail.com, google-adm...@googlegroups.com
Hi there,

1. To test how to use GDPR form, feel free to use our test ad id. To test the GDPR message you set in the UI, you would need your own credentials.

2. MobileAds initialization has to happen AFTER consent is gathered. Initialize MobileAds only when ConsentInformation.CanRequestAds() is true.

3. No, you only need to call ConsentInformation.Update on every app launch.

Thanks,
Jill
Google Mobile Ads SDK Team

ref:!00D1U01174p.!5004Q02qCQpf:ref

HamsterSY

unread,
Nov 21, 2023, 10:51:07 PM11/21/23
to Google Mobile Ads SDK Developers

Hi

1. I not sure what are my own credentials, but i can watch ad with apk in nox player.
Is it means i already have it or i need to do something?

2. I find some infomation on Google AdMob > Mobile Ads SDK(Unity)
https://developers.google.com/admob/unity/mediation/unity#turn-on-test-mode

In "Turn on test mode" that say can set test mode and add test Devic via Unity ads Dashboard.
Is i miss this part so i can't get GDPR message?

Still need help, thanks.
Mobile Ads SDK Forum Advisor 在 2023年11月22日 星期三凌晨12:24:24 [UTC+8] 的信中寫道:

HamsterSY

unread,
Nov 22, 2023, 2:37:09 AM11/22/23
to Google Mobile Ads SDK Developers
Update new question

About request debugSettings:


var debugSettings = new ConsentDebugSettings
{
    // Geography appears as in EEA for debug devices.
    DebugGeography      = DebugGeography.EEA,
    TestDeviceHashedIds = new List<string>
    {
        "MyDeviceID"
    }
};

How can i check my send device id are correct?

And to test GDPR, is i need to add my device id to other where like Admob UI?

Mobile Ads SDK Forum Advisor 在 2023年11月22日 星期三凌晨12:24:24 [UTC+8] 的信中寫道:
Hi there,

HamsterSY

unread,
Nov 27, 2023, 7:34:11 AM11/27/23
to Google Mobile Ads SDK Developers
Hi
I use Android Studio get device id and it work!
Can play ad when accept consent.
But when i use ConsentInformation.Reset() and click Manage option then disable all Consent 
and click Confirm choices, the ad can't play and i use  ConsentInformation.Reset() still can't play ad, why?

Also i find AdMob tutorial can use ConsentInformation.CanRequestAds() check can request or not, but my GoogleMobileAds version
no have this function, have instead way?

Thanks.


Mobile Ads SDK Forum Advisor 在 2023年11月22日 星期三凌晨12:24:24 [UTC+8] 的信中寫道:
Hi there,

Mobile Ads SDK Forum Advisor

unread,
Nov 28, 2023, 10:12:50 AM11/28/23
to ujham...@gmail.com, google-adm...@googlegroups.com
Hey HamsterSY,

We need to see what's actually in the ad request to tell if everything is working as intended. You can also verify on your own.

Use https://developers.google.com/admob/android/ad-inspector#advanced_ad_unit_debugging with ad inspector to get the ad request URL. Look for these parameters, &gdpr=1&gdpr_consent=...&addtl_consent=... to see if they have anything specified. "gdpr=1" means that you have obtained consent using the UMP SDK. Let us know if you have further issue.

Thanks,
Jill, Google Mobile Ads SDK Team

ref:!00D1U01174p.!5004Q02qCQpf:ref

HamsterSY

unread,
Nov 30, 2023, 11:56:14 AM11/30/23
to Google Mobile Ads SDK Developers

Hi

I'm not sure i need use this or not.
But i find when first time GDPR consent show, click manage options and just select confirm choices
then the ad will no fill.
Next show GDPR consent again and just click consent and now ad will fill and play.

Have some question
1. So click and manage options and just select confirm choices will make ad no fill.
How i can i know what consent need accept?Have a list?

2. After question 1 i re show consent and just select consent can play ad,
is it like Privacy options?

Thank you.
Mobile Ads SDK Forum Advisor 在 2023年11月28日 星期二晚上11:12:50 [UTC+8] 的信中寫道:

HamsterSY

unread,
Dec 1, 2023, 2:08:40 AM12/1/23
to Google Mobile Ads SDK Developers
Hi
Finally i try use  ad inspector get ad request, have a question:
the request URL will be empty when ad not fill?

By the way, when i accept all consent, the ad will fill and i can get request URL.
I search &gdpr=.. and find the value, yes i find "gdpr=1"!
So is mean obtained consent using the UMP SDK success?

Thank you.
AdInspector.pngGDPRRequestURL.png

Mobile Ads SDK Forum Advisor 在 2023年11月28日 星期二晚上11:12:50 [UTC+8] 的信中寫道:
Hey HamsterSY,

Mobile Ads SDK Forum Advisor

unread,
Dec 1, 2023, 11:32:34 AM12/1/23
to ujham...@gmail.com, google-adm...@googlegroups.com

Hello,

The gdpr is set to 1 because GDPR applies. The value will be 1 whether you consent or do not consent. gdpr_consent is the GDPR consent parameter. It appears to be working as intended. Ad Inspector also appears to be working as intended.

To answer your original questions:

1.) I believe the reason you aren't seeing any ads, though, is that in addition to providing purposes consent (the first screen that you see when clicking "Manage Options") you also need to provide vendor consent (scroll to bottom of purposes page -> click "Vendor preferences"). Both purposes consent and vendor consent are required for any vendor (for example, Google) to work properly/show ads.

2.) You can re-show consent again by using the privacy options APIs. See our Privacy options section for information.  

Thanks,
Justin



ref:!00D1U01174p.!5004Q02qCQpf:ref
Reply all
Reply to author
Forward
0 new messages