FirebaseAnalytics 모듈을 가져오고 이메일 주소 또는 전화번호를 initiateOnDeviceConversionMeasurement() API에 전달합니다.
importFirebaseAnalytics// ...// If you're using an email address....Analytics.initiateOnDeviceConversionMeasurement(emailAddress:"example@gmail.com")// If you're using a phone number....Analytics.initiateOnDeviceConversionMeasurement(phoneNumber:"+15555555555")
@importFirebaseAnalytics;// ...// If you're using an email address....[FIRAnalyticsinitiateOnDeviceConversionMeasurementWithEmailAddress:@"example@gmail.com"];// If you're using a phone number....[FIRAnalyticsinitiateOnDeviceConversionMeasurementWithPhoneNumber:@"+15555555555"];
usingFirebase.Analytics;// ...// If you're using an email address....FirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithEmailAddress("example@gmail.com");// If you're using a phone number....FirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithPhoneNumber("+15555555555");
해싱된 이메일 주소 또는 전화번호 사용
API는 SHA256으로 해싱된 이메일 주소와 전화번호를 허용합니다. SDK를 호출하기 전에 코드에서 해싱을 실행하여 사용자 데이터를 계속 제어할 수 있습니다.
해싱된 사용자 인증 정보를 사용하려면 주소와 숫자를 표준화하고 SHA256으로 해싱한 다음 API를 호출합니다.
이메일 주소 및 전화번호 정규화
이메일 주소의 경우 Google Analytics API는 SHA256이 적용되기 전에 특정 정규화가 실행된다고 가정합니다. 따라서 다음 단계에 따라 데이터를 정규화하세요.
전체 이메일 주소를 소문자로 변환합니다.
이메일 주소가 도메인 @googlemail.com으로 끝나는 경우 @googlemail.com 도메인을 @gmail.com으로 대체합니다.
전화번호의 경우 SHA256으로 해싱하기 전에 이미 E.164 형식 (즉, 접두사 +, 국가 코드 1~3자리, 구독자 번호 최대 12자리)이어야 합니다.
해싱된 SHA256 이메일 또는 전화번호는 16진수 문자열이 아닌 32바이트 길이여야 합니다.
해싱된 사용자 인증 정보로 API 호출
Swift
FirebaseAnalytics 모듈을 가져오고 이메일 주소 또는 전화번호를 initiateOnDeviceConversionMeasurement() API에 전달합니다.
importFirebaseAnalytics// ...// If you're using an email address....Analytics.initiateOnDeviceConversionMeasurement(hashedEmailAddress:hashedEmailAddress)// If you're using a phone number....Analytics.initiateOnDeviceConversionMeasurement(hashedPhoneNumber:hashedPhoneNumber)
@importFirebaseAnalytics;// ...// If you're using an email address....[FIRAnalyticsinitiateOnDeviceConversionMeasurementWithHashedEmailAddress:hashedEmailAddress];// If you're using a phone number....[FIRAnalyticsinitiateOnDeviceConversionMeasurementWithHashedPhoneNumber:hashedPhoneNumber];
usingFirebase.Analytics;// ...// If you're using an email address....FirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithHashedEmailAddress(hashedEmailAddress);// If you're using a phone number....FirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithHashedPhoneNumber(hashedPhoneNumber);
Xcode 디버그 로그로 확인 (선택사항)
디버그 모드를 사용 설정한 경우, initiate measurement API를 호출한 후 Xcode 디버그 콘솔에 다음과 같은 로그 메시지와 유사한 메시지가 표시되는지 확인합니다.
[null,null,["최종 업데이트: 2025-07-25(UTC)"],[],[],null,["Step 3: Initiate on-device conversion measurement using Google Analytics\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------|\n| Introduction: [Measure iOS Ads conversions](/docs/tutorials/ads-ios-on-device-measurement/index-first-party) |\n| Step 1: [Implement a sign-in experience](/docs/tutorials/ads-ios-on-device-measurement/step-1) \u003cbr /\u003e |\n| [Step 2: Integrate Google Analytics](/docs/tutorials/ads-ios-on-device-measurement/step-2) |\n| **Step 3: Initiate on-device conversion measurement using Google Analytics** \u003cbr /\u003e |\n| Step 4: [Troubleshoot and handle common issues](/docs/tutorials/ads-ios-on-device-measurement/step-4) |\n\n\u003cbr /\u003e\n\nNow that you can collect users' email addresses and phone numbers and your app has the\nGoogle Analytics for Firebase SDK, you can use the two to start\nmeasuring conversions.\n\nCall the API\n\nCall the conversion measurement API with the consented email address or phone\nnumber from Step 1, which is used for ads conversion measurement, without\nallowing any personally identifiable information to leave the user device.\n\nThere are two ways to initiate measurement:\n\n- [Using credentials](#use-plain-text-credentials)\n- [Using hashed credentials](#use-hashed-credentials)\n\nUse email address or phone number \n\nSwift\n\nImport the `FirebaseAnalytics` module and pass in the email address or phone\nnumber to the `initiateOnDeviceConversionMeasurement()` API.\n**Note:** The `initiateOnDeviceConversionMeasurement(emailAddress:)` and `initiateOnDeviceConversionMeasurement(phoneNumber:)` methods may be called sequentially, but only one match can be reported per user. If a match is found with either API, then subsequent API call are effectively ignored. \n\n```swift\nimport FirebaseAnalytics\n\n// ...\n// If you're using an email address....\nAnalytics.initiateOnDeviceConversionMeasurement(emailAddress: \"example@gmail.com\")\n// If you're using a phone number....\nAnalytics.initiateOnDeviceConversionMeasurement(phoneNumber: \"+15555555555\")\n```\n\nObjective-C\n\nImport the `FirebaseAnalytics` module and pass in the email address to the\n`initiateOnDeviceConversionMeasurementWithEmailAddress:` API or the phone\nnumber to the `initiateOnDeviceConversionMeasurementWithPhoneNumber:` API.\n**Note:** The `initiateOnDeviceConversionMeasurementWithEmailAddress:` and `initiateOnDeviceConversionMeasurementWithPhoneNumber:` methods may be called sequentially, but only one match can be reported per user. If a match is found with either API, then subsequent API call are effectively ignored. \n\n```objective-c\n@import FirebaseAnalytics;\n\n// ...\n// If you're using an email address....\n[FIRAnalytics initiateOnDeviceConversionMeasurementWithEmailAddress:@\"example@gmail.com\"];\n// If you're using a phone number....\n[FIRAnalytics initiateOnDeviceConversionMeasurementWithPhoneNumber:@\"+15555555555\"];\n```\n\nUnity\n\nImport the `Firebase.Analytics` namespace and pass in the email address to the\n`InitiateOnDeviceConversionMeasurementWithEmailAddress()` API or the phone\nnumber to the `InitiateOnDeviceConversionMeasurementWithPhoneNumber()` API:\n**Note:** The `InitiateOnDeviceConversionMeasurementWithEmailAddress()` and `InitiateOnDeviceConversionMeasurementWithPhoneNumber()` methods may be called sequentially, but only one match can be reported per user. If a match is found with either API, then subsequent API call are effectively ignored. \n\n```c#\nusing Firebase.Analytics;\n\n// ...\n// If you're using an email address....\nFirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithEmailAddress(\"example@gmail.com\");\n// If you're using a phone number....\nFirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithPhoneNumber(\"+15555555555\");\n```\n| **Note:** The best practice is to call the API once per install and as close as possible to the login.\n| **Important:** Be aware that if an intended in-app action or event happens *immediately* after a user email or phone registration, consider implementing a small time delay between initiating on-device conversion measurement and logging the event.\n\nUse a hashed email address or phone number\n\nThe API will accept email addresses and phone numbers hashed with SHA256. You\ncan maintain control of your user's data by performing the hashing in your code\nbefore making calls to the SDK.\n\nTo use hashed credentials, normalize addresses and numbers, hash them with\nSHA256, then call the API.\n\nNormalize email addresses and phone numbers\n\nFor **email addresses** , the Google Analytics API assumes that a\nparticular normalization is performed before SHA256 is applied, so follow these\nsteps to normalize your data:\n\n1. Convert the entire email address to lowercase.\n\n2. If the email address ends in domain *@googlemail.com* , replace the\n *@googlemail.com* domain with *@gmail.com*.\n\n3. For addresses ending in domain *@gmail.com* (including those modified in\n the previous step):\n\n 1. Remove all periods from the username portion.\n\n 2. Make the following substitutions in the username portion:\n\n - For letters I or i, or digit 1, substitute letter l\n - For digit 0, substitute letter o\n - For digit 2, substitute letter z\n - For digit 5, substitute letter s\n\nFor example, after normalization:\n\n- `an.email.user0125@googlemail.com` becomes `anemalluserolzs@gmail.com`\n- `CAPSUSER0125@provider.net` becomes `capsuser0125@provider.net`\n\nFor **phone numbers**, numbers must already be in E.164 format (that is,\nprefix with +, 1-3 digits for country code, max 12 digits for subscriber number)\nprior to hashing with SHA256.\n\nNote that the hashed SHA256 email or phone numbers must be 32 bytes long\nand not a hexadecimal string.\n\nCall the API with hashed credentials \n\nSwift\n\nImport the `FirebaseAnalytics` module and pass in the email address or phone\nnumber to the `initiateOnDeviceConversionMeasurement()` API.\n**Note:** The `initiateOnDeviceConversionMeasurement(hashedEmailAddress:)` and `initiateOnDeviceConversionMeasurement(hashedPhoneNumber:)` methods may be called sequentially, but only one match can be reported per user. If a match is found with either API, then subsequent API call are effectively ignored. \n\n```swift\nimport FirebaseAnalytics\n\n// ...\n// If you're using an email address....\nAnalytics.initiateOnDeviceConversionMeasurement(hashedEmailAddress: hashedEmailAddress)\n// If you're using a phone number....\nAnalytics.initiateOnDeviceConversionMeasurement(hashedPhoneNumber: hashedPhoneNumber)\n```\n\nObjective-C\n\nImport the `FirebaseAnalytics` module and pass in the email address to the\n`initiateOnDeviceConversionMeasurementWithHashedEmailAddress:` API or the phone\nnumber to the `initiateOnDeviceConversionMeasurementWithHashedPhoneNumber:`\nAPI.\n**Note:** The `initiateOnDeviceConversionMeasurementWithHashedEmailAddress:` and `initiateOnDeviceConversionMeasurementWithHashedPhoneNumber:` methods may be called sequentially, but only one match can be reported per user. If a match is found with either API, then subsequent API call are effectively ignored. \n\n```objective-c\n@import FirebaseAnalytics;\n\n// ...\n// If you're using an email address....\n[FIRAnalytics initiateOnDeviceConversionMeasurementWithHashedEmailAddress:hashedEmailAddress];\n// If you're using a phone number....\n[FIRAnalytics initiateOnDeviceConversionMeasurementWithHashedPhoneNumber:hashedPhoneNumber];\n```\n\nUnity\n\nImport the `Firebase.Analytics` namespace and pass in the email address to the\n`InitiateOnDeviceConversionMeasurementWithHashedEmailAddress()` API or the\nphone number to the `InitiateOnDeviceConversionMeasurementWithHashedPhoneNumber()` API:\n**Note:** The `InitiateOnDeviceConversionMeasurementWithHashedEmailAddress()` and `InitiateOnDeviceConversionMeasurementWithHashedPhoneNumber()` methods may be called sequentially, but only one match can be reported per user. If a match is found with either API, then subsequent API call are effectively ignored. \n\n```c#\nusing Firebase.Analytics;\n\n// ...\n// If you're using an email address....\nFirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithHashedEmailAddress(hashedEmailAddress);\n// If you're using a phone number....\nFirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithHashedPhoneNumber(hashedPhoneNumber);\n```\n| **Note:** The best practice is to call the API once per install and as close as possible to the login.\n| **Important:** Be aware that if an intended in-app action or event happens *immediately* after a user email or phone registration, consider implementing a small time delay between initiating on-device conversion measurement and logging the event.\n\nVerify with Xcode debug logs (optional)\n\nIf you enabled debug mode, after calling the initiate measurement API, ensure\nthat a message like the following log message appears in the Xcode debug\nconsole: \n\n [FirebaseAnalytics][I-ACS023225] Initiated on-device conversion measurement\n\nIf you enabled debug mode and included the `-DebugOnDeviceConversionMeasurement`\nlaunch argument, then calling the `initiateOnDeviceConversionMeasurement()` API\nwill simulate a match. \n\n [FirebaseAnalytics][I-ACS023229] On-device conversion measurement found a match\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\n\u003cbr /\u003e\n\n[arrow_back_ios**Step 2** : Integrate Google Analytics](/docs/tutorials/ads-ios-on-device-measurement/step-2)\n[**Step 4** : Troubleshoot and handle common issuesarrow_forward_ios](/docs/tutorials/ads-ios-on-device-measurement/step-4)\n\n\u003cbr /\u003e\n\n*** ** * ** ***"]]