1
\$\begingroup\$

I'm creating a Unity game that uses admob mediation to show rewarded ads. I'm using about 5-10 different ad networks.

How do I implement GDPR compliance for EU users?

I tried following some online tutorials, but none of them had content showing getting GDPR consent for multiple networks.

How can I modify this script to correctly get compliance where needed for all of my ad networks?

public class Mediation : MonoBehaviour
{
 string Video_Ad_Id = "ca-app-pub-3940256099942544/5224354917";
 private RewardedAd rewardedAd;
 public Button reviveBtn;

 void Start()
 {
    MobileAds.Initialize((initStatus) =>
    {
        Dictionary<string, AdapterStatus> map = initStatus.getAdapterStatusMap();
        foreach (KeyValuePair<string, AdapterStatus> keyValuePair in map)
        {
            string className = keyValuePair.Key;
            AdapterStatus status = keyValuePair.Value;
            switch (status.InitializationState)
            {
                case AdapterState.NotReady:
                    // The adapter initialization did not complete.
                    MonoBehaviour.print("Adapter: " + className + " not ready.");
                    break;
                case AdapterState.Ready:
                    // The adapter was successfully initialized.
                    MonoBehaviour.print("Adapter: " + className + " is initialized.");
                    break;
            }
        }
    });

    RequestRewardBasedVideo();
}

void Update()
{
    if (rewardedAd.IsLoaded())
    {
        reviveBtn.interactable = true;
    }
}

I'm not sure where to ask for consent as I'm using multiple ad networks and not just admob. In the documentation, there is this line of code:

AdRequest request = new AdRequest.Builder().AddExtra("npa", "1") .Build();

Where do I add this in the script above and how do I ask for consent for multiple networks, like Chartboost, Adcolony, ironSource etc?

EDIT

I have added the following code to the mainmenu script which loads up when the game starts.

public GameObject GDPR_Popup; 
void Start()
{
    Invoke("CheckForGDPR",.25f);
}

void CheckForGDPR()
{
    if (PlayerPrefs.GetInt("npa", -1) == -1)
    {
        GDPR_Popup.SetActive(true);             
    }
}


public void OnUserClickAccept()
{
    PlayerPrefs.SetInt("npa", 0); //this is for google admob
    AdColonyAppOptions.SetGDPRConsentString("1");
    AppLovin.SetHasUserConsent(true);       
    GDPR_Popup.SetActive(false);
}

public void OnUserClickCancel()
{
    PlayerPrefs.SetInt("npa", 1);//this is for google admob
    AdColonyAppOptions.SetGDPRConsentString("0");
    AppLovin.SetHasUserConsent(false);  
    GDPR_Popup.SetActive(false);        
}

Would something like this work as I'm not sure how to test this?

Also, how to initialize the ad networks only when the user has accepted or canceled GDPR option(this I believe was mentioned in the google admob mediation documents but there was no code sample given).

Can someone please help?

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Did you read AdMob documentation for GDPR compliance? There you must find code snippets to set consent true when users press the accept button on the GPDR consent screen. \$\endgroup\$ – Syed Munim Raza Nov 13 '20 at 7:52
  • \$\begingroup\$ @SyedMunimRaza, I have added admob script. I'm not sure where to ask for consent as I'm using multiple adnetworks and not just admob. In the documentation, there is this line of code "AdRequest request = new AdRequest.Builder() .AddExtra("npa", "1") .Build();" Where do I add this in the script above. \$\endgroup\$ – single arrow games Nov 13 '20 at 14:04
1
\$\begingroup\$

At a glance from the From the Mobile Ads SDK (Unity) documentation for Requesting Consent from European Users, this doesn't look like the sort of thing that you can do with a one line addition to a script:

Mediation networks Google currently is unable to obtain and handle consent for mediation networks, so you'll need to obtain and handle consent for each ad network separately. We are actively working with all of our open source and versioned mediation networks to provide updated documentation with details on how to forward consent. Documentation is already live for the following mediation networks:

  • AppLovin
  • Chartboost
  • Facebook
  • MoPub
  • myTarget
  • Tapjoy
  • Unity Ads
  • Vungle

I randomly looked at a few of these & they each seem to have their own unique instructions. As far as I can tell, you'll need to follow up on each network individually.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.