How do I Set Consent For Personalized Ads in Google Mobile Ads Unity Plugin v9.2.0?

69 views
Skip to first unread message

Thom Web

unread,
Oct 8, 2024, 5:12:03 AM10/8/24
to Google Mobile Ads SDK Developers
I'm making an Android game using Unity.

I have this public variable:
public bool consentForPersonalizedAds;

I've created a consent panel myself for personalized ads with two buttons:
Button Yes: To show personalized ads (consentForPersonalizedAds = true)
Button No: To not show personalized ads (consentForPersonalizedAds = false)

I've downloaded the latest 'Google Mobile Ads Unity Plugin v9.2.0' from:
https://github.com/googleads/googleads-mobile-unity/releases

Now to my question.
How can I give to the 'Google Mobile Ads Unity Plugin' the consent value for showing or not showing personalized ads?

In the old Google Mobile Ads Unity Plugin versions I did it like that:
request = new AdRequest.Builder()
.AddExtra("npa", "1") // This indicates non-personalized ads .Build();

I haven't found a solution in the documentation.

Mobile Ads SDK Forum Advisor

unread,
Oct 9, 2024, 1:22:35 AM10/9/24
to thomasw...@gmail.com, google-adm...@googlegroups.com

Hi Thom,

Thank you for contacting the Mobile Ads SDK support team.

You should request an update of the user's consent information at every app launch, using Update(). To give the GMA the consent value to show or not show personalized ads, you need to set the user's consent status using the privacy settings within the GMA Unity plugin, typically by implementing a consent flow where you ask the user for permission to collect and use their data for personalized ads, and then pass this consent flag to the SDK when requesting ads.

// After obtaining user consent:
bool consentForPersonalizedAds = true; // Set to true if user consented
bool consentForPersonalizedAds = false; // Set to false if user consented

// In your ad request code:
/// Ensures that privacy and consent information is up to date.
       private void InitializeGoogleMobileAdsConsent()
       {
           Debug.Log("Google Mobile Ads gathering consent.");
           _consentController.GatherConsent((string error) =>
           {
               if (error != null)
               {
                   Debug.LogError("Failed to gather consent with error: " +
                       error);
               }
               else
               {
                   Debug.Log("Google Mobile Ads consent updated: "
                       + ConsentInformation.ConsentStatus);
               }
               if (_consentController.CanRequestAds)
               {
                   InitializeGoogleMobileAds();
               }
           });
       }

Also, refer to the Google Unity sample application as a reference for your implementation. 

This message is in relation to case "ref:!00D1U01174p.!5004Q02vGcjk:ref" (ADR-00270939)

Thanks,
 
Google Logo Mobile Ads SDK Team


Reply all
Reply to author
Forward
0 new messages