Collecting Consent with Usercentrics¶
Before jumping into any code, let's review some basic rules for collecting user consent:
When should you collect consent?¶
In general, you are free to decide when to collect consent from your users. e.g. Right after app launch, after a demo game, during user activation, etc.
There are only 2 requirements you need to follow to be compliant with data protection:
Requirement 1
Do NOT enable any data tracking from 3rd party services/SDKs before a user has given explicit consent. This would otherwise be a breach of data protection regulations, which can result in heavy fines.
Requirement 2
Don't forget Requirement 1.
Integrating Usercentrics¶
First, from Usercentrics/Prefabs
, drag the Usercentrics
Prefab into your Scene.
Automatic Init¶
Use Case
Use Automatic Init to present the banner automatically when a scene starts. This integration only supports using our Usercentrics UI, which can be customized via our Configuration Dashboard. For a custom integration, please continue to Custom Init.
-
Enable Auto Initialize in the Inspector Tab. When the Scene is shown for the first time, the consent banner will appear automatically when needed.
-
Done! 🚀 Please continue to Apply Consent.
Custom Init¶
Use Case
Use Custom Init to have more control over the behaviour of the banner and the collected consent. This integration supports creating your own Banner, which can unlock a much higher performance for opt-in rates.
Disable Auto Initialize
For a custom integration, please make sure Auto Initialize is disabled.
-
Import
Usercentrics
to the Sceneusing Unity.Usercentrics;
-
On Scene start, call
Initialize()
from aUsercentrics
instance. On success, evaluatestatus.shouldCollectConsent
.Usercentrics.Instance.Initialize((status) => { if (status.shouldCollectConsent) { // Collect Consent } else { // Apply Consent with status.consents } },(errorMessage) => { // Failure: Returns non-localized error });
Handling
status.shouldCollectConsent
shouldCollectConsent
will let you know if you should present the banner. e.g If consent has never been collected, or if the banner needs to be shown again do to changes on your configuration.If consent has already been collected, you can simply apply the consent given, which will be available in
status.consent
-
Present the Consent Banner when
status.shouldCollectConsent
is TRUE.
Presenting the Consent Banner¶
UsercentricsUI¶
Use our out-of-the-box UI component, that owns all the complexity of compliance, and can be customized via our Configuration Dashboard. Continue to UsercentricsUI.
Build your own Banner¶
Build a Banner that fits your game design language, and let us take care of the rest. Continue to Build your own UI.
Only for IAB TCF 2.0 certified customers
Currently you can only use this solution if you are building a Banner that adheres to the IAB's TCF 2.0 Standard. For this you will need to be certified as a CMP by the IAB.