Informationen zu den SDKs finden Sie in den Google-Entwicklerleitfäden:
Funktionen des Google-Einwilligungsmodus-SDK
Die allgemeinen SDK-Anforderungen und die Implementierung finden Sie in den Leitfäden am Anfang dieses Dokuments. Wenn Sie die Unterstützung des Einwilligungsmodus in „Datenschutz & Mitteilungen“ aktiviert haben, können Sie auch die hier beschriebenen zusätzlichen Funktionen implementieren.
Einwilligungsmodus: Unterstützung des einfachen Modus
Nachdem Sie das entsprechende SDK implementiert, den Google-Einwilligungsmodus in „Datenschutz & Mitteilungen“ aktiviert, und sich für die Implementierung des einfachen Einwilligungsmodus entschieden haben, folgen Sie dieser Anleitung.
So implementieren Sie den einfachen Modus:
- Deaktivieren Sie vorübergehend die Analytics-Erhebung (Android, iOS).
- Wenn Sie die Google Analytics-Funktionen wieder aktivieren möchten, aktivieren Sie die Analytics-Erhebung wieder (Android, iOS).
Für Schritt 2 sollten Sie einen Rechtsexperten hinzuziehen, um die Kriterien für die Reaktivierung der Analytics-Funktionen festzulegen.
Sie können die Google Analytics-Funktionen beispielsweise wieder aktivieren, nachdem der Nutzer eine Einwilligung erteilt hat. Dazu reaktivieren Sie die Google Analytics-Funktionen im
Callback von loadAndShowConsentFormIfRequired (API-Referenz:
Android,
iOS).
Alternativ können Sie den lokalen Speicherschlüssel UMP_consentModeValues lesen, um zu ermitteln, ob die Analytics-Erhebung basierend auf den Entscheidungen des Nutzers zum Einwilligungsmodus wieder aktiviert werden soll. Der Wert ist ein vierstelliges String.
- Die erste Ziffer gibt den Wert des Zwecks „ad_storage“ an.
- Die zweite Ziffer gibt den Wert des Zwecks „ad_user_data“ an.
- Die dritte Ziffer gibt den Wert des Zwecks „ad_personalization“ an.
- Die vierte Ziffer gibt den Wert des Zwecks „analytics_storage“ an.
In der folgenden Tabelle sind die möglichen Werte für jede Ziffer beschrieben:
| Wert | Bedeutung |
|---|---|
0 |
Es ist noch kein Wert verfügbar. |
1 |
Der Nutzer hat GRANTED für diesen Zweck angegeben. |
2 |
Der Nutzer hat DENIED für diesen Zweck angegeben. |
3 |
Der Einwilligungsmodus gilt nicht für diesen Nutzer. |
4 |
Der Einwilligungsmodus ist für diesen Zweck nicht konfiguriert. |
Im folgenden Beispiel wird UMP_consentModeValues geparst. Google Analytics wird aktiviert, wenn für alle Zwecke GRANTED angegeben ist oder sie nicht gelten. Andernfalls wird die Analytics-Erhebung deaktiviert:
Java
// Helper function that sets Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
private void maybeReEnableAnalyticsCollection() {
String consentModeValues = sharedPreferences.getString("UMP_consentModeValues", null);
if (shouldReEnableAnalyticsCollection(consentModeValues)) {
firebaseAnalytics.setAnalyticsCollectionEnabled(true);
} else {
firebaseAnalytics.setAnalyticsCollectionEnabled(false);
}
}
// Helper function to determine whether Analytics collection should be enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.
private boolean shouldReEnableAnalyticsCollection(String consentModeValues) {
if (consentModeValues.isEmpty()) {
return false;
}
for (int i = 0; i < consentModeValues.length(); i++) {
char consentModeValue = consentModeValues.charAt(i);
switch (consentModeValue) {
case '0':
// Consent mode data not ready yet.
return false;
case 1:
// Consent mode is granted for this purpose.
break;
case '2':
// Consent is denied for this consent mode purpose.
return false;
case '3':
// Consent does not apply for this purpose at this time.
break;
case '4':
// Consent mode is not configured for this purpose.
break;
default:
// Unexpected value encountered.
return false;
}
}
// If all checks pass, re-enable Analytics collection.
return true;
}
Kotlin
// Helper function that may re-enable Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
private fun maybeReEnableAnalyticsCollection() {
val consentModeValues = sharedPreferences.getString("UMP_consentModeValues", null)
if (shouldReEnableAnalyticsCollection(consentModeValues)) {
firebaseAnalytics.setAnalyticsCollectionEnabled(true)
}
}
// Helper function to determine whether Analytics collection should be re-enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.
private fun shouldReEnableAnalyticsCollection(consentModeValues: String?): Boolean {
if (consentModeValues.isNullOrEmpty()) {
return false
}
for (consentModeValue in consentModeValues) {
when (consentModeValue) {
'0' -> {
// Consent mode data not ready yet.
return false
}
'1' -> {
// Consent mode is granted for this purpose.
}
'2' -> {
// Consent is denied for this consent mode purpose.
return false
}
'3' -> {
// Consent does not apply for this purpose at this time.
}
'4' -> {
// Consent mode is not configured for this purpose.
}
else -> {
// Unexpected value encountered.
return false
}
}
}
// If all checks pass, can re-enable Analytics collection.
return true
}
Swift
// Helper function that may re-enable Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
private func maybeReEnableAnalyticsCollection() {
let consentModeValues = userDefaults.string(forKey: "UMP_consentModeValues")
if shouldReEnableAnalyticsCollection(consentModeValues) {
Analytics.setAnalyticsCollectionEnabled(true)
}
}
// Helper function to determine whether Analytics collection should be re-enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.
private func shouldReEnableAnalyticsCollection(_ consentModeValues: String?) -> Bool {
guard let consentModeValues = consentModeValues, !consentModeValues.isEmpty else {
return false
}
for consentModeValue in consentModeValues {
switch consentModeValue {
case "0":
// Consent mode data not ready yet.
return false
case "1":
// Consent mode is granted for this purpose.
break
case "2":
// Consent is denied for this consent mode purpose.
return false
case "3":
// Consent does not apply for this purpose at this time.
break
case "4":
// Consent mode is not configured for this purpose.
break
default:
// Unexpected value encountered.
return false
}
}
// If all checks pass, can re-enable Analytics collection.
return true
}
Objective-C
// Helper function that may re-enable Analytics collection based on the value of the
// UMP_consentModeValues local storage key.
- (void)maybeReEnableAnalyticsCollection {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *consentModeValues = [defaults stringForKey:@"UMP_consentModeValues"];
if ([self shouldReEnableAnalyticsCollection:consentModeValues]) {
[FIRAnalytics setAnalyticsCollectionEnabled:YES];
}
}
// Helper function to determine whether Analytics collection should be re-enabled. Returns true
// if all consent mode values are either granted, not applicable, or not configured.
- (BOOL)shouldReEnableAnalyticsCollection:(NSString *)consentModeValues {
if (!consentModeValues || [consentModeValues length] == 0) {
return NO;
}
for (NSUInteger i = 0; i < [consentModeValues length]; i++) {
unichar consentModeValue = [consentModeValues characterAtIndex:i];
switch (consentModeValue) {
case '0':
// Consent mode data not ready yet.
return NO;
case '1':
// Consent mode is granted for this purpose.
break;
case '2':
// Consent is denied for this consent mode purpose.
return NO;
case '3':
// Consent does not apply for this purpose at this time.
break;
case '4':
// Consent mode is not configured for this purpose.
break;
default:
// Unexpected value encountered.
return NO;
}
}
// If all checks pass, can re-enable Analytics collection.
return YES;
}
Rufen Sie maybeReEnableAnalyticsCollection auf, wenn:
- die Einwilligungsinformationen aktualisiert werden
- die Einwilligung eingeholt wird.