3단계: Google Analytics를 사용하여 온디바이스 전환 측정 시작
| 소개: iOS 광고 전환 측정 |
|
1단계: 로그인 환경 구현 |
| 2단계: Google Analytics 통합 |
|
3단계: Google Analytics를 사용하여 온디바이스 전환 측정 시작하기 |
| 4단계: 일반적인 문제 해결 및 처리 |
이제 사용자의 이메일 주소와 전화번호를 수집할 수 있고 앱에 Firebase SDK의 Google Analytics가 있으므로 이 두 가지를 사용하여 전환 측정을 시작할 수 있습니다.
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 호출 권장사항
정확하고 지속적인 온디바이스 전환 측정을 보장하려면 다음 중 하나를 수행하세요.
모든 앱 업데이트에서 호출 (권장)
Firebase SDK 버전 12.1.0 이상의 Google Analytics에는 온디바이스 전환 측정 개선사항이 포함되어 있습니다. 앱이 업데이트되기 전에 이미 로그인한 사용자를 포함한 모든 사용자에게 이러한 개선사항이 적용되도록 하려면 앱이 업데이트된 후 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이 적용되기 전에 특정 정규화가 실행된다고 가정하므로 다음 단계에 따라 데이터를 정규화하세요.
이메일 주소 전체를 소문자로 변환합니다.
이메일 주소가 도메인 @googlemail.com으로 끝나는 경우 @googlemail.com 도메인을 @gmail.com으로 바꿉니다.
도메인 @gmail.com으로 끝나는 주소 (이전 단계에서 수정된 주소 포함)의 경우:
사용자 이름 부분에서 모든 마침표를 삭제합니다.
사용자 이름 부분에서 다음과 같이 바꿉니다.
- 문자 I 또는 i, 숫자 1의 경우 문자 l로 대체
- 숫자 0은 문자 o로 대체합니다.
- 숫자 2를 문자 z로 대체
- 숫자 5를 문자 s로 대체
예를 들어 정규화 후에는 다음과 같습니다.
an.email.user0125@googlemail.com이anemalluserolzs@gmail.com이 됩니다.CAPSUSER0125@provider.net이capsuser0125@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단계: 일반적인 문제 해결 및 처리