Skip to main content

Integrate with Google On Device Measurement

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.

note

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 SDKGoogle 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
}
warning

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();