Google 동의 관리 솔루션 SDK

SDK에 관한 Google Developers 가이드를 확인하세요.


전반적인 SDK 요구사항 및 구현은 이 문서의 시작 부분에 있는 가이드를 참고하세요. 개인 정보 보호 및 메시지의 동의 모드 지원을 사용 설정한 경우 여기에 설명된 추가 기능을 구현하는 것이 좋습니다.

관련 SDK를 구현하고 개인 정보 보호 및 메시지에서 Google 동의 모드를 사용 설정한 후 기본 동의 모드를 구현하기로 결정한 경우 다음 안내를 따르세요.

기본 모드를 구현하려면 다음 단계를 따르세요.

  1. 애널리틱스 수집을 일시적으로 사용 중지합니다 (Android, iOS).
  2. Google 애널리틱스 기능을 차단 해제할 준비가 되면 애널리틱스 수집을 다시 사용 설정합니다 (Android, iOS).

2단계에서는 법률 전문가와 상담하여 애널리틱스 기능을 다시 사용 설정하기 위한 기준을 결정하세요.

예를 들어 사용자가 동의를 선택한 후 loadAndShowConsentFormIfRequired (API 참조: Android, iOS)의 콜백에서 Google 애널리틱스 기능을 다시 사용 설정하여 Google 애널리틱스 기능을 다시 사용 설정할 수 있습니다.

또는 사용자의 동의 모드 선택에 따라 애널리틱스 수집을 다시 사용 설정할지 여부를 결정하려면 UMP_consentModeValues 로컬 스토리지 키를 읽으세요. 값은 4자리 문자열입니다.

  • 첫 번째 숫자는 ad_storage 목적 값을 나타냅니다.
  • 두 번째 숫자는 ad_user_data 목적 값을 나타냅니다.
  • 세 번째 숫자는 ad_personalization 목적 값을 나타냅니다.
  • 네 번째 숫자는 analytics_storage 목적 값을 나타냅니다.

다음 표에서는 각 숫자의 가능한 값을 설명합니다.

의미
0 아직 사용할 수 있는 값이 없습니다.
1 사용자가 이 목적을 GRANTED했습니다.
2 사용자가 이 목적을 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을 호출합니다.

  • 동의 정보가 업데이트됨
  • 동의가 수집됨