Unity Ads Not Loading After Consent Dialog - GDPR and SDK Fix
Problem: Your Unity game shows a GDPR/consent dialog, but after the player clicks to allow/opt in, Unity Ads never loads (no banner/rewarded/interstitial appears). In logs, you may see symptoms like initialization happened too early, ad requests returning failures, or callbacks not firing as expected.
Root Cause: In most cases, the consent decision is not applied to the Unity Ads SDK before (or at the moment) ad initialization and load requests occur. If the SDK is initialized before consent signals are set, or if you request ads in the same flow as consent without waiting for the consent callback, the SDK may refuse targeting/data processing and your later load calls won’t recover.
This fix focuses on one reliable rule: apply consent signals, then initialize and load ads.
Quick Fix Solutions
Solution 1: Gate Advertisement.Initialize and ad loads behind the consent callback
Problem: Ads are requested before the consent flow finishes, or the consent signal is never passed into the Unity Ads SDK.
Steps:
- Make consent an asynchronous gate.
- Start your consent flow (Unity CMP, your CMP, UMP, etc.) on launch.
- Wait for the user decision.
- Only when you have an explicit result (opt-in / opt-out) should you proceed to ad SDK initialization and ad load calls.
- Pass the decision to Unity Ads GDPR consent APIs.
- Unity’s GDPR docs describe privacy/consent APIs (example concepts include
setUserConsent()/setUserOptOut()and related signals).
- Unity’s GDPR docs describe privacy/consent APIs (example concepts include
- Initialize Unity Ads after consent signals are set.
Minimal code pattern (illustrative):
using UnityEngine;
using UnityEngine.Advertisements;
public class ConsentGateAds : MonoBehaviour, IUnityAdsInitializationListener
{
[SerializeField] string gameId = "YOUR_GAME_ID";
[SerializeField] bool testMode = true;
void Start()
{
// 1) Begin consent flow here (Unity CMP / UMP / your CMP).
// 2) Then call InitializeAdsOnceConsentIsKnown(optIn);
}
public void InitializeAdsOnceConsentIsKnown(bool optIn)
{
// 3) Apply consent signal to the Unity Ads SDK (per Unity GDPR docs).
// Names can vary by Unity Ads version; follow the official consent API docs.
Advertisement.setUserConsent(optIn);
// 4) Initialize after consent is applied.
Advertisement.Initialize(gameId, testMode, this);
}
public void OnInitializationComplete()
{
// Now it is safe to load/show ads.
// Advertisement.Load(...) / Advertisement.Show(...)
}
public void OnInitializationFailed(UnityAdsInitializationError error, string message)
{
Debug.LogError($"Unity Ads init failed: {error} - {message}");
}
}
Verification:
- Enable debug logging for Unity Ads in your dev build.
- Run on a device in the EEA (or use Unity Ads testing that triggers the consent behavior).
- Confirm:
- consent dialog appears
- you receive the consent result callback
OnInitializationCompletefires after consent is applied- you can load/show at least one ad format successfully
Solution 2: If you initialized too early, re-initialize after the consent decision
Problem: Advertisement.Initialize ran before consent was known.
Steps:
- Move
Advertisement.Initializeout ofStart()/Awake()if it runs before consent. - If you can’t refactor immediately:
- ensure ad load/show calls do not happen until after consent
- set the consent signal on the SDK once the player decides
- then call
Advertisement.Initializeagain (using the samegameIdand appropriatetestMode)
Verification:
- Add one log line right before the re-initialization call.
- Confirm initialization complete fires after the consent click, not earlier.
Solution 3: Remove “instant load” calls from the consent flow
Problem: You call Load/Show in the same place where you display the consent dialog, but before the SDK knows the final state.
Steps:
- Search your code for ad calls (
Load,Show, rewarded/interstitial/banner requests). - Ensure those calls run only inside the consent callback (or a function invoked from it).
- Remove any startup coroutines that queue ad loads without checking consent completion.
Verification:
- Temporarily add
Debug.Logright before each ad load call. - Confirm no ad load runs until after you have the consent decision result.
Solution 4: Confirm your “opt-out” behavior matches GDPR expectations
Problem: The player opts out, but your code still tries to load targeted ads as if consent were granted.
Steps:
- If opt-out means “no personalized ads,” ensure your logic:
- does not request/show targeted placements
- optionally uses non-behavioral/contextual signals if supported by your Unity Ads privacy API usage
- If you support both:
- keep two code paths: opt-in load vs opt-out fallback
Verification:
- Test both opt-in and opt-out.
- Confirm the behavior is consistent with what Unity Ads privacy APIs are set to.
Prevention Tips
- Treat consent as an asynchronous dependency: “no consent result, no ads init, no ads load.”
- Centralize ad initialization in one place (one “AdController” component) so you don’t accidentally initialize from multiple scripts.
- Never request ads on the same frame as showing the consent dialog.
- Keep “test mode” IDs separate from production IDs (and verify you are testing with the correct build configuration).
Related Problems and Links
- If ads fail for reasons other than consent, see: Ad Integration Not Working in Unity - Monetization Fixes
- For core Unity integration patterns, see: Unity Guides
Official Documentation (GDPR / Consent)
- GDPR compliance (Unity Ads)
- Implementing data privacy and consent signals (Unity Ads)
- Testing Ads in Unity
Bookmark this fix for quick reference. If ads still do not load after gating initialization behind consent, share your consent callback flow (where you call initialization and where you call load/show) so you can pinpoint the exact timing mistake.