اکنون که می توانید آدرس ایمیل و شماره تلفن کاربران را جمع آوری کنید و برنامه شما دارای Google Analytics برای Firebase SDK است، می توانید از این دو برای شروع اندازه گیری تبدیل ها استفاده کنید.
با API تماس بگیرید
API اندازهگیری تبدیل را با آدرس ایمیل یا شماره تلفن مورد رضایت از مرحله 1، که برای اندازهگیری تبدیل تبلیغات استفاده میشود، تماس بگیرید، بدون اینکه اجازه دهید هیچ اطلاعات شناسایی شخصی از دستگاه کاربر خارج شود.
ماژول FirebaseAnalytics را وارد کنید و آدرس ایمیل یا شماره تلفن را به API initiateOnDeviceConversionMeasurement() ارسال کنید.
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")
هدف-C
ماژول FirebaseAnalytics را وارد کنید و آدرس ایمیل را به initiateOnDeviceConversionMeasurementWithEmailAddress: API یا شماره تلفن را به initiateOnDeviceConversionMeasurementWithPhoneNumber: API ارسال کنید.
@importFirebaseAnalytics;// ...// If you're using an email address....[FIRAnalyticsinitiateOnDeviceConversionMeasurementWithEmailAddress:@"example@gmail.com"];// If you're using a phone number....[FIRAnalyticsinitiateOnDeviceConversionMeasurementWithPhoneNumber:@"+15555555555"];
وحدت
فضای نام Firebase.Analytics را وارد کنید و آدرس ایمیل را به API InitiateOnDeviceConversionMeasurementWithEmailAddress() یا شماره تلفن را به API InitiateOnDeviceConversionMeasurementWithPhoneNumber() ارسال کنید:
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 جایگزین کنید.
برای آدرسهایی که به دامنه @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 می شود
برای شمارههای تلفن ، اعداد باید قبلاً در قالب E.164 باشند (یعنی پیشوند با +، 1-3 رقم برای کد کشور، حداکثر 12 رقم برای شماره مشترک) قبل از هش کردن با SHA256.
توجه داشته باشید که ایمیل یا شماره تلفن هش شده SHA256 باید 32 بایت باشد و یک رشته هگزا دسیمال نباشد.
با اطلاعات کاربری هش شده با API تماس بگیرید
سویفت
ماژول FirebaseAnalytics را وارد کنید و آدرس ایمیل یا شماره تلفن را به API initiateOnDeviceConversionMeasurement() ارسال کنید.
importFirebaseAnalytics// ...// If you're using an email address....Analytics.initiateOnDeviceConversionMeasurement(hashedEmailAddress:hashedEmailAddress)// If you're using a phone number....Analytics.initiateOnDeviceConversionMeasurement(hashedPhoneNumber:hashedPhoneNumber)
هدف-C
ماژول FirebaseAnalytics را وارد کنید و آدرس ایمیل را به initiateOnDeviceConversionMeasurementWithHashedEmailAddress: API یا شماره تلفن را به initiateOnDeviceConversionMeasurementWithHashedPhoneNumber: API ارسال کنید.
@importFirebaseAnalytics;// ...// If you're using an email address....[FIRAnalyticsinitiateOnDeviceConversionMeasurementWithHashedEmailAddress:hashedEmailAddress];// If you're using a phone number....[FIRAnalyticsinitiateOnDeviceConversionMeasurementWithHashedPhoneNumber:hashedPhoneNumber];
وحدت
فضای نام Firebase.Analytics را وارد کنید و آدرس ایمیل را به API InitiateOnDeviceConversionMeasurementWithHashedEmailAddress() یا شماره تلفن را به InitiateOnDeviceConversionMeasurementWithHashedPhoneNumber() API ارسال کنید:
usingFirebase.Analytics;// ...// If you're using an email address....FirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithHashedEmailAddress(hashedEmailAddress);// If you're using a phone number....FirebaseAnalytics.InitiateOnDeviceConversionMeasurementWithHashedPhoneNumber(hashedPhoneNumber);
تأیید با گزارشهای اشکالزدایی Xcode (اختیاری)
اگر حالت اشکال زدایی را فعال کرده اید، پس از فراخوانی API اندازه گیری شروع، مطمئن شوید که پیامی مانند پیام گزارش زیر در کنسول اشکال زدایی Xcode ظاهر می شود:
اگر حالت اشکال زدایی را فعال کرده باشید و آرگومان راه اندازی -DebugOnDeviceConversionMeasurement را وارد کرده باشید، آنگاه فراخوانی API initiateOnDeviceConversionMeasurement() یک تطابق را شبیه سازی می کند.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[],[],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*** ** * ** ***"]]