SDK에 관한 Google 개발자 가이드를 확인하세요.
Google 동의 모드 SDK 기능
전체 SDK 요구사항 및 구현에 관한 내용은 이 문서 시작 부분의 가이드를 참고하세요. 개인 정보 보호 및 메시지의 동의 모드 지원을 사용 설정한 경우 여기에 설명된 추가 기능을 구현하는 것이 좋습니다.
동의 모드: 기본 모드 지원
관련 SDK를 구현하고, 개인 정보 보호 및 메시지에서 Google 동의 모드를 사용 설정하고, 기본 동의 모드를 구현하기로 결정한 후 다음 안내를 따르세요.
기본 모드를 구현하려면 다음 단계를 따르세요.
- 애널리틱스 수집을 일시적으로 사용 중지합니다 (Android, iOS).
- Google 애널리틱스 기능을 차단 해제할 준비가 되면 애널리틱스 수집을 다시 사용 설정합니다 (Android, iOS).
2단계에서는 법률 전문가와 상의하여 애널리틱스 기능을 다시 사용 설정하기 위한 기준을 결정합니다.
예를 들어 사용자가 동의 여부를 선택한 후 loadAndShowConsentFormIfRequired
의 콜백에서 Google 애널리틱스 기능을 다시 사용 설정하여 Google 애널리틱스 기능을 다시 사용 설정할 수 있습니다 (API 참조: Android, iOS).
또는 사용자의 동의 모드 선택에 따라 애널리틱스 수집을 다시 사용 설정할지 결정하려면 UMP_consentModeValues
로컬 스토리지 키를 읽습니다. 값은 4자리 문자열입니다.
- 첫 번째 숫자는 ad_storage 목적 값을 나타냅니다.
- 두 번째 숫자는 ad_user_data 목적 값을 나타냅니다.
- 세 번째 숫자는 ad_personalization purpose 값을 나타냅니다.
- 네 번째 숫자는 analytics_storage 목적 값을 나타냅니다.
다음 표에는 각 자리에 사용할 수 있는 값이 나와 있습니다.
값 | 의미 |
---|---|
0 |
아직 값을 사용할 수 없습니다. |
1 |
사용자 GRANTED 가 이 목적을 GRANTED 했습니다. |
2 |
사용자 DENIED 가 이 목적을 DENIED 했습니다. |
3 |
이 사용자에게는 동의 모드가 적용되지 않습니다. |
4 |
동의 모드는 이 용도로 구성되지 않았습니다. |
다음 예에서는 UMP_consentModeValues
를 파싱하고 모든 목적이 GRANTED
이거나 적용되지 않는 경우 Google 애널리틱스를 사용 설정하고 그렇지 않은 경우에는 애널리틱스 수집을 사용 중지합니다.
자바
// 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;
}
다음과 같은 경우 maybeReEnableAnalyticsCollection
를 호출합니다.
- 동의 정보가 업데이트됨
- 동의를 수집합니다.