튜토리얼: iOS 광고 전환 측정

3단계: Google Analytics을(를) 사용하여 온디바이스 전환 측정 시작하기


소개: iOS 광고 전환 측정
1단계: 로그인 환경 구현하기
2단계: 통합하기 Google Analytics

3단계: 온디바이스 전환 측정 시작하기Google Analytics

4단계: 일반적인 문제 해결 및 처리하기


이제 사용자의 이메일 주소와 전화번호를 수집할 수 있고 앱에 Firebase용 Google Analytics SDK가 있으므로 이 두 가지를 사용하여 전환 측정을 시작할 수 있습니다.

API 호출

개인 식별 정보가 사용자 기기에서 유출되지 않도록 하면서 광고 전환 측정에 사용되는 1단계의 동의한 이메일 주소 또는 전화번호를 사용하여 전환 측정 API를 호출합니다.

측정을 시작하는 방법에는 두 가지가 있습니다.

이메일 주소 또는 전화번호 사용

Swift

FirebaseAnalytics 모듈을 가져오고 이메일 주소 또는 전화번호를 initiateOnDeviceConversionMeasurement() API에 전달합니다.

import FirebaseAnalytics

// ...
// If you're using an email address....
Analytics.initiateOnDeviceConversionMeasurement(emailAddress: "example@gmail.com")
// If you're using a phone number....
Analytics.initiateOnDeviceConversionMeasurement(phoneNumber: "+15555555555")

Objective-C

FirebaseAnalytics 모듈을 가져오고 이메일 주소를 initiateOnDeviceConversionMeasurementWithEmailAddress: API에 전달하거나 전화번호를 initiateOnDeviceConversionMeasurementWithPhoneNumber: API에 전달합니다.

@import FirebaseAnalytics;

// ...
// If you're using an email address....
[FIRAnalytics initiateOnDeviceConversionMeasurementWithEmailAddress:@"example@gmail.com"];
// If you're using a phone number....
[FIRAnalytics initiateOnDeviceConversionMeasurementWithPhoneNumber:@"+15555555555"];

Unity

Firebase.Analytics 네임스페이스를 가져오고 이메일 주소를 InitiateOnDeviceConversionMeasurementWithEmailAddress() API에 전달하거나 전화번호를 InitiateOnDeviceConversionMeasurementWithPhoneNumber() API에 전달합니다.

using Firebase.Analytics;

// ...
// If you're using an email address....
FirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithEmailAddress("example@gmail.com");
// If you're using a phone number....
FirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithPhoneNumber("+15555555555");

API 호출 권장사항

정확하고 지속적인 온디바이스 전환 측정을 위해 다음 중 하나를 실행합니다.

Google Analytics for Firebase SDK 버전 12.1.0 이상에는 온디바이스 전환 측정 개선사항이 포함되어 있습니다. 이러한 개선사항이 앱이 업데이트되기 전에 이미 로그인한 사용자를 포함한 모든 사용자에게 적용되도록 하려면 앱이 업데이트된 후 initiateOnDeviceConversionMeasurement API를 다시 호출하는 것이 중요합니다.

특히 앱이 SDK 버전 12.1.0으로 업데이트되기 전에 로그인한 사용자는 initiateOnDeviceConversionMeasurement API가 다시 호출될 때까지 향상된 측정 범위에 포함되지 않습니다. 앱 업데이트 확인이 없으면 로그아웃했다가 다시 로그인하는 경우에만 이 작업이 실행됩니다.

권장사항은 로그인한 사용자를 위해 앱 버전당 한 번 이상 API를 호출하는 것입니다. 앱 실행 시 확인을 구현하여 마지막 호출 이후 앱 버전이 변경된 경우에만 API를 호출할 수 있습니다.

Swift

// On app launch if the app version has changed, call the API with the first-party data
// (for example: email address, phone number, hashed email address, hashed phone number).
let cachedAppVersion = UserDefaults.standard.string(forKey: "cachedAppVersion")
let currentAppVersion =
    Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String

if cachedAppVersion != currentAppVersion {
  let hashedEmailAddress = ...
  Analytics.initiateOnDeviceConversionMeasurement(hashedEmailAddress: hashedEmailAddress)
  UserDefaults.standard.set(currentAppVersion, forKey: "cachedAppVersion")
}

Objective-C

// On app launch if the app version has changed, call the API with the first-party data
// (for example: email address, phone number, hashed email address, hashed phone number).
NSString *cachedAppVersion =
    [[NSUserDefaults standardUserDefaults] stringForKey:@"cachedAppVersion"];
NSString *currentAppVersion = [[NSBundle mainBundle]
    objectForInfoDictionaryKey:@"CFBundleShortVersionString"];

if (![cachedAppVersion isEqualToString:currentAppVersion]) {
  NSString *hashedEmailAddress = ...
  [FIRAnalytics initiateOnDeviceConversionMeasurementWithHashedEmailAddress:hashedEmailAddress];
  [[NSUserDefaults standardUserDefaults] setObject:currentAppVersion
                                            forKey:@"cachedAppVersion"];
}

Unity

// On app launch if the app version has changed, call the API with the first-party data
// (for example: email address, phone number, hashed email address, hashed phone number).
string cachedAppVersion = PlayerPrefs.GetString("cached_app_version", "");
string currentAppVersion = Application.version;

if (cachedAppVersion != currentAppVersion) {
  byte[] hashedEmailAddress = ...
  FirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithHashedEmailAddress(
      hashedEmailAddress);
  PlayerPrefs.SetString("cached_app_version", currentAppVersion);
  PlayerPrefs.Save();
}

로그인 직후 호출

사용자가 이메일 또는 전화번호로 로그인하거나 등록한 직후에는 항상 initiateOnDeviceConversionMeasurement API를 호출합니다.

신규 등록의 타이밍 고려사항

사용자가 등록한 직후에 주요 전환 이벤트가 발생하고 API를 호출하는 경우 API 호출과 주요 이벤트 로깅 사이에 약간의 지연(예: 5초)을 구현하는 것이 좋습니다. 이렇게 하면 이벤트가 로깅되기 전에 온디바이스 측정이 완전히 초기화됩니다.

해싱된 이메일 주소 또는 전화번호 사용

API는 SHA256으로 해싱된 이메일 주소와 전화번호를 허용합니다. SDK를 호출하기 전에 코드에서 해싱을 실행하여 사용자 데이터를 제어할 수 있습니다.

해싱된 사용자 인증 정보를 사용하려면 주소와 번호를 정규화하고 SHA256으로 해싱한 다음 API를 호출합니다.

이메일 주소 및 전화번호 정규화

이메일 주소의 경우 Google Analytics API는 SHA256이 적용되기 전에 특정 정규화가 실행된다고 가정하므로 다음 단계에 따라 데이터를 정규화합니다.

  1. 전체 이메일 주소를 소문자로 변환합니다.

  2. 이메일 주소가 도메인 @googlemail.com으로 끝나는 경우 @googlemail.com 도메인을 @gmail.com으로 바꿉니다.

  3. 이전 단계에서 수정된 주소를 포함하여 @gmail.com 도메인으로 끝나는 주소의 경우 다음을 실행합니다.

    1. 사용자 이름 부분에서 모든 마침표를 삭제합니다.

    2. 사용자 이름 부분에서 다음을 바꿉니다.

      • 문자 I 또는 i 또는 숫자 1의 경우 문자 l로 바꿉니다.
      • 숫자 0의 경우 문자 o로 바꿉니다.
      • 숫자 2의 경우 문자 z로 바꿉니다.
      • 숫자 5의 경우 문자 s로 바꿉니다.

예를 들어 정규화 후에는 다음과 같이 됩니다.

  • an.email.user0125@googlemail.comanemalluserolzs@gmail.com으로 바뀝니다.
  • CAPSUSER0125@provider.netcapsuser0125@provider.net으로 바뀝니다.

전화번호의 경우 SHA256으로 해싱하기 전에 번호가 이미 E.164 형식 (즉, +로 시작, 국가 코드 1~3자리, 가입자 번호 최대 12자리 )이어야 합니다.

해싱된 SHA256 이메일 또는 전화번호는 길이가 32바이트여야 하며 16진수 문자열이 아니어야 합니다.

해싱된 사용자 인증 정보로 API 호출

Swift

FirebaseAnalytics 모듈을 가져오고 이메일 주소 또는 전화번호를 initiateOnDeviceConversionMeasurement() API에 전달합니다.

import FirebaseAnalytics

// ...
// If you're using an email address....
Analytics.initiateOnDeviceConversionMeasurement(hashedEmailAddress: hashedEmailAddress)
// If you're using a phone number....
Analytics.initiateOnDeviceConversionMeasurement(hashedPhoneNumber: hashedPhoneNumber)

Objective-C

FirebaseAnalytics 모듈을 가져오고 이메일 주소를 initiateOnDeviceConversionMeasurementWithHashedEmailAddress: API에 전달하거나 전화번호를 initiateOnDeviceConversionMeasurementWithHashedPhoneNumber: API에 전달합니다.

@import FirebaseAnalytics;

// ...
// If you're using an email address....
[FIRAnalytics initiateOnDeviceConversionMeasurementWithHashedEmailAddress:hashedEmailAddress];
// If you're using a phone number....
[FIRAnalytics initiateOnDeviceConversionMeasurementWithHashedPhoneNumber:hashedPhoneNumber];

Unity

Firebase.Analytics 네임스페이스를 가져오고 이메일 주소를 InitiateOnDeviceConversionMeasurementWithHashedEmailAddress() API에 전달하거나 전화번호를 InitiateOnDeviceConversionMeasurementWithHashedPhoneNumber() API에 전달합니다.

using Firebase.Analytics;

// ...
// If you're using an email address....
FirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithHashedEmailAddress(hashedEmailAddress);
// If you're using a phone number....
FirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithHashedPhoneNumber(hashedPhoneNumber);

통합 확인

디버그 모드를 사용 설정합니다. 측정 시작 API를 호출한 후 다음과 같은 로그 메시지가 Xcode 디버그 콘솔에 표시되는지 확인합니다.

[FirebaseAnalytics][I-ACS023225] Initiated on-device conversion measurement

디버그 모드를 사용 설정하고 -DebugOnDeviceConversionMeasurement 실행 인수를 포함한 경우 initiateOnDeviceConversionMeasurement() API를 호출하면 일치 항목이 시뮬레이션됩니다.

[FirebaseAnalytics][I-ACS023229] On-device conversion measurement found a match




2단계: Google Analytics 4단계: 일반적인 문제 해결 및 처리