Step 3: Initiate on-device conversion measurement using Google Analytics
Introduction: Measure iOS Ads conversions |
Step 1: Implement a sign-in experience |
Step 2: Integrate Google Analytics |
Step 3: Initiate on-device conversion measurement using Google Analytics |
Step 4: Troubleshoot and handle common issues |
Now that you can collect users' email addresses and phone numbers and your app has the Google Analytics for Firebase SDK, you can use the two to start measuring conversions.
Call the API
Call the initiateOnDeviceConversionMeasurement()
API with the consented email
address or phone number from Step 1, which is used for ads conversion
measurement, without allowing any personally identifiable information to leave
the user device.
Swift
Import the FirebaseAnalytics
module and pass in the email address or phone
number to the 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
Import the FirebaseAnalytics
module and pass in the email address to the
initiateOnDeviceConversionMeasurementWithEmailAddress:
API or the phone
number to the 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
Import the Firebase.Analytics
namespace and pass in the email address to the
InitiateOnDeviceConversionMeasurementWithEmailAddress()
API or the phone
number to the 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");
Verify with debug logs (optional)
If you enabled debug mode, after calling the initiateOnDeviceConversionMeasurement()
API, ensure that a message like the following log message appears in the Xcode debug console:
9.0.0 - [FirebaseAnalytics][I-ACS023225] Initiated on-device conversion measurement
In Firebase 9.6.0 or later, if you enabled debug mode and included the
-DebugOnDeviceConversionMeasurement
launch argument, then calling the
initiateOnDeviceConversionMeasurement()
API will simulate a match.
9.6.0 - [FirebaseAnalytics][I-ACS023229] On-device conversion measurement found a match
Step 2: Integrate Google AnalyticsStep 4: Troubleshoot and handle common issues