If you aren’t able to directly integrate the on-device conversion measurement solution with the Google Analytics for Firebase (GA4F) SDK, you can do it with a standalone SDK.
In this article, you’ll learn how to integrate, use, and troubleshoot the on-device conversion measurement SDK.
Learn more About on-device conversion measurement for iOS App campaigns.
On this page
Integrate the standalone SDK
You can access the on-device conversion measurement standalone SDK via CocoaPods and Swift Package Manager.
Swift Package Manager
- In Xcode, go to File, then Add Packages.
- Select the GoogleAdsOnDeviceConversion GitHub repository in the prompt.
After you're finished, Xcode will begin resolving your package dependencies and downloading them in the background.
CocoaPods
- Add the GoogleAdsOnDeviceConversion pod to your Podfile.
pod 'GoogleAdsOnDeviceConversion'
- Run
pod install --repo-update
.
Use the GoogleAdsOnDeviceConversion SDK
After you retrieve the on-device conversion measurement SDK, fetch the conversion information shortly after the app first launches, for both first_open
and reinstall_open
conversions.
Swift
- Install the GoogleAdsOnDeviceConversion SDK to enable privacy-preserving on-device conversion measurement for iOS app campaigns.
import GoogleAdsOnDeviceConversion
- Set the time to when the app was first launched.
ConversionManager.sharedInstance.setFirstLaunchTime(Date())
- Fetch the conversion information.
ConversionManager.sharedInstance.fetchAggregateConversionInfo(for: .installation)
{ aggregateConversionInfo, error in
guard error == nil else { return }
guard let info = aggregateConversionInfo else { return }
guard info.count > 0 else { return }
print("Conversion info \(info)")
}
Objective C
- Install the GoogleAdsOnDeviceConversion SDK to enable privacy-preserving on-device conversion measurement for iOS app campaigns.
import GoogleAdsOnDeviceConversion
- Set the time to when the app was first launched.
[[ODCConversionManager sharedInstance] setFirstLaunchTime:[NSDate date]];
- Fetch the conversion information.
[[ODCConversionManager sharedInstance]
fetchAggregateConversionInfoForInteraction:ODCInteractionTypeInstallation
completion:^(NSString * _Nullable aggregateConversionInfo,
NSError * _Nullable error) {
if (error) return;
if (aggregateConversionInfo.length == 0) return;
NSLog(@"Conversion info %@", aggregateConversionInfo);
// Use aggregateConversionInfo as the value in the odm_info query parameter in the
// App Conversion API.// For example, if aggregateConversionInfo is "abcdEfadGdaf",
// then odm_info=abcdEfadGdaf.
}];
Troubleshooting steps
-
Check if the date passed to
setFirstLaunchTime()
was when the app first launched. -
Check that your app is running in the European Economic Area (EEA), the United Kingdom and Switzerland.
Ensure to use info as the value in the odm_info
query parameter in the App Conversion API.
// For example, if info is "abcdEfadGdaf", then odm_info=abcdEfadGdaf