Integrate with Google On Device Measurement
This page covers every SDK platform and version. A part that applies only to some platforms starts with Platform: …, and a part that applies only to some SDK versions starts with SDK version: ….
If you use Google Ads, you can integrate Google On Device Measurement (ODM) with the justtrack SDK. The Google ODM adapter fetches on-device conversion data from the Google Ads On Device Conversion SDK and forwards it to the justtrack backend, enabling more accurate attribution of app installs driven by Google Ads campaigns.
Before you begin
Before you integrate the Google ODM adapter, you need to add the GoogleAdsOnDeviceConversion SDK to your project. The justtrack Google ODM adapter depends on it to fetch on-device conversion data.
To add the GoogleAdsOnDeviceConversion SDK:
-
Add the dependency to your
Podfile:pod 'GoogleAdsOnDeviceConversion', '~> 1.0' -
Run
pod installto install the dependency. -
Set the first launch time as early as possible in your app's lifecycle (for example, in
application(_:didFinishLaunchingWithOptions:)):import GoogleAdsOnDeviceConversionfunc application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {let firstLaunchKey = "key.firstLaunchTime"let defaults = UserDefaults.standardif let storedDate = defaults.object(forKey: firstLaunchKey) as? Date {ConversionManager.sharedInstance.setFirstLaunchTime(storedDate)} else {let now = Date()defaults.set(now, forKey: firstLaunchKey)ConversionManager.sharedInstance.setFirstLaunchTime(now)}// ... rest of your app initializationreturn true}warningYou must call
setFirstLaunchTimebefore the justtrack SDK initializes. If you don't set the first launch time, the Google ODM adapter can't fetch conversion data correctly.
Please review the following compatibility matrix to make sure you're using compatible versions:
| justtrack SDK | Google ODM Adapter | GoogleAdsOnDeviceConversion SDK |
|---|---|---|
| 7.1.0+ | 1.x | 1.x |
Integrate with Google ODM
First, add the adapter dependency to your package manager:
- Cocoa Pods
- Swift Package Manager
- Carthage
pod 'JustTrackSDKGoogleOdmAdapter', '~> 1.0.0'
https://github.com/justtrackio/justtrack-sdk-spm.git
binary "https://sdk.justtrack.io/carthage/JustTrackSDKGoogleOdmAdapter.json"
Then, initialize the adapter, and integrate it with the justtrack SDK:
import JustTrackSDK
import JustTrackSDKGoogleOdmAdapter
// Build the SDK
let sdk = try JustTrackSdkBuilder(apiToken: apiToken)
.set(trackingId: trackingId, trackingProvider: trackingProvider)
.build()
// Integrate the Google ODM adapter
sdk.integrate(with: JusttrackGoogleOdmAdapter())
The Google ODM adapter doesn't require any parameters. It automatically fetches on-device conversion data and forwards it to the justtrack backend.
Google On Device Measurement (ODM) integration currently is not available for the justtrack Android SDK.
Platform: React NativeIf you use Google Ads, you can integrate Google On Device Measurement (ODM) with the justtrack SDK. The Google ODM adapter fetches on-device conversion data from the Google Ads On Device Conversion SDK and forwards it to the justtrack backend, enabling more accurate attribution of app installs driven by Google Ads campaigns.
Google ODM integration is only available on iOS. On Android, calling registerAdapter() results in a rejected promise.
Before you begin
Please review the following compatibility matrix to make sure you're using compatible versions:
| justtrack SDK | Google ODM Adapter |
|---|---|
| 7.1.0+ | 1.x |
Integrate with Google ODM
Step 1: Set the first launch time
The Google Ads On Device Conversion SDK requires you to set the first launch time as early as possible in your app's lifecycle. In your AppDelegate.swift, override application(_:didFinishLaunchingWithOptions:) and call setFirstLaunchTime before the justtrack SDK initializes:
import UIKit
import React
import React_RCTAppDelegate
import GoogleAdsOnDeviceConversion
@UIApplicationMain
class AppDelegate: RCTAppDelegate {
override func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Set the first launch time for Google ODM
let firstLaunchKey = "key.firstLaunchTime"
let defaults = UserDefaults.standard
if defaults.object(forKey: firstLaunchKey) == nil {
let now = Date()
defaults.set(now, forKey: firstLaunchKey)
ConversionManager.sharedInstance.setFirstLaunchTime(now)
} else if let storedDate = defaults.object(forKey: firstLaunchKey) as? Date {
ConversionManager.sharedInstance.setFirstLaunchTime(storedDate)
}
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
// ... rest of your AppDelegate
}
You must call setFirstLaunchTime before the justtrack SDK initializes. If you don't set the first launch time, the Google ODM adapter can't fetch conversion data correctly.
Step 2: Install the adapter
npm install justtrack-adapter-google-odm --save
Then, run pod install in the ios/ directory.
Step 3: Register the adapter
Register the adapter after initializing the justtrack SDK:
import { registerAdapter as registerGoogleOdmAdapter } from 'justtrack-adapter-google-odm';
// Register the adapter after initializing the justtrack SDK
registerGoogleOdmAdapter();
If you use Google Ads, you can integrate Google On Device Measurement (ODM) with the justtrack SDK. The Google ODM adapter fetches on-device conversion data from the Google Ads On Device Conversion SDK and forwards it to the justtrack backend, enabling more accurate attribution of app installs driven by Google Ads campaigns.
Google ODM integration is only available on iOS. On Android, calling IntegrateWithGoogleOdm() results in a failure callback.
Before you begin
Review the following compatibility matrix to make sure you're using compatible versions. Automatic uses the default version.
| Platform | Google ODM Adapter | GoogleAdsOnDeviceConversion SDK |
|---|---|---|
| iOS | 1.x (default) | 1.x |
Integrate with Google ODM
-
In the Unity Editor, navigate to the justtrack SDK configuration prefab.
-
Select the iOS tab, and enable Add Google ODM Adapter. This adds the Google ODM adapter to your project for iOS.
-
Optional: In Adapter Version, choose the adapter version that matches your GoogleAdsOnDeviceConversion SDK. See Choose an adapter version.
-
Add the following native iOS plugin files to your Unity project under
Assets/Plugins/iOS/GoogleOdm/. These files set the first launch time, which the Google Ads On Device Conversion SDK requires to correctly measure conversions.ODMFirstLaunchTime.swift:import Foundationimport GoogleAdsOnDeviceConversion@objc public class ODMFirstLaunchTime: NSObject {@objc public static func setup() {let firstLaunchKey = "key.firstLaunchTime"let defaults = UserDefaults.standardif defaults.object(forKey: firstLaunchKey) == nil {let now = Date()defaults.set(now, forKey: firstLaunchKey)ConversionManager.sharedInstance.setFirstLaunchTime(now)print("Set ODM first launch time: \(now)")} else if let storedDate = defaults.object(forKey: firstLaunchKey) as? Date {ConversionManager.sharedInstance.setFirstLaunchTime(storedDate)print("Restored ODM first launch time: \(storedDate)")}}}AppController.mm:#import "UnityAppController.h"#import <UnityFramework/UnityFramework-Swift.h>@interface AppController : UnityAppController@endIMPL_APP_CONTROLLER_SUBCLASS(AppController)@implementation AppController- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey, id> *)launchOptions {[ODMFirstLaunchTime setup];return [super application:application didFinishLaunchingWithOptions:launchOptions];}@endwarningYou must call
setFirstLaunchTimebefore the justtrack SDK initializes. TheJustTrackAppControllerabove handles this by calling[ODMFirstLaunchTime setup]inapplication:didFinishLaunchingWithOptions:, which runs before the SDK starts. -
Call the integration method in your code:
using JustTrack;
// Call this after SDK initialization
JustTrackSDK.IntegrateWithGoogleOdm(
pOnSuccess: () => {
Debug.Log("Google ODM integration successful");
},
pOnFailure: (error) => {
Debug.LogError($"Google ODM integration failed: {error}");
}
);
Choose an adapter version
You can choose which adapter version the justtrack SDK adds to your project. After you enable an adapter, an Adapter Version menu appears below it with these options:
- Automatic: Uses the default adapter version for your installed justtrack SDK. Use this option unless your third-party SDK version needs a different adapter.
- A specific version, such as 1.0.0 or 2.0.0: Uses the latest stable release of that major version. Choose the version that matches your third-party SDK in the compatibility matrix.
- Custom: Lets you enter any version. Enter an adapter version that's already published. If the version doesn't exist, the justtrack SDK uses the default version instead.
Google On Device Measurement (ODM) integration currently is not available for the justtrack Flutter SDK.