Integrating the SDK
Requirements:
- Android API 16
- iOS Target 13.0
- Xcode 15.3
Supported Platforms:
- Android
- iOS
Data Privacy:
Migration:
If you are migrating from a Kochava SDK prior to version 2.0.0 to version 2.x usage can be updated by reviewing the code samples for any given topic, as the overall usage of the SDK remains the same.
Integration:
In order to use the Kochava SDK, first add it within your project. This can be accomplished using pub.dev (recommended) or by downloading the SDK files manually and adding them.
- Add the Kochava Measurement plugin to your pubspec.yaml file. Replace “x.y.z” with the latest version obtained from the Download Badge above.
kochava_measurement: ^x.y.z
To align with Apple’s Privacy Manifest requirements, the ability to collect and transmit the IDFA has been moved into a separate, optional tracking module. Without this module included, the SDK will not collect or transmit the IDFA. To include these tracking capabilities, add the Kochava Measurement Apple Tracking plugin to your pubspec.yaml file, replacing “x.y.z” with the latest version obtained from the Download Badge above.
kochava_measurement_apple_tracking: ^x.y.z
- Download the kochava_measurement.zip from the Download Badge above.
- Extract the zip file into the root directory of your project.
- Add the Kochava Measurement plugin to your pubspec.yaml file.
kochava_measurement: path: ./kochava_measurement
To include the optional tracking module manually:
- Download the kochava_measurement_apple_tracking.zip from the Download Badge above.
- Extract the zip file into the root directory of your project.
- Add the Kochava Measurement Apple Tracking plugin to your pubspec.yaml file.
kochava_measurement: path: ./kochava_measurement_apple_tracking
Google Play Store:
If you wish for the SDK to collect the Google Play Ads Identifier (ADID), App Set ID (ASID) and/or make use of the Install Referrer, you must integrate Google Play Services by adding the appropriate dependencies. Collection is handled by the Kochava SDK with only the dependency itself needing to be included. The Kochava SDK does not require specific versions of its dependencies however we recommend keeping them up to date whenever possible.
Maven Repository —
google()
Dependencies —
implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1'
NOTE: If using a version prior to version 17.1.0 you must also add the following permission.
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
implementation 'com.android.installreferrer:installreferrer:2.2'
implementation 'com.google.android.gms:play-services-appset:16.0.2'
Huawei App Gallery:
If you wish for the SDK to collect the Huawei Advertising ID (OAID) and/or make use of the Install Referrer, you must integrate the Huawei Ads SDK by adding the appropriate dependencies. Collection is handled by the Kochava SDK with only the dependency itself needing to be included. The Kochava SDK does not require specific versions of its dependencies however we recommend keeping them up to date whenever possible.
Maven Repository —
maven { url 'https://developer.huawei.com/repo/' }
Dependencies —
implementation 'com.huawei.hms:ads-identifier:3.4.39.302'
implementation 'com.huawei.hms:ads-installreferrer:3.4.39.302'
Samsung Galaxy Store:
SDK VERSION NOTE: This feature requires Kochava Android SDK Version 4.3.0 or higher.
If you wish for the SDK to collect and/or make use of the Samsung Install Referrer, you must integrate Samsung Install Referrer by adding the appropriate dependencies. Collection is handled by the Kochava SDK with only the dependency itself needing to be included. The Kochava SDK does not require specific versions of its dependencies however we recommend keeping them up to date whenever possible.
implementation 'store.galaxy.samsung.installreferrer:samsung_galaxystore_install_referrer:4.0.0'
Samsung Cloud Gaming:
SDK VERSION NOTE: This feature requires Kochava Android SDK Version 5.2.0 or higher.
If you wish for the SDK to collect and/or make use of the local user’s ADID (CGID) when running in the cloud gaming environment, you must integrate the Samsung Cloud Dev SDK by adding the appropriate dependencies and permissions. Collection is handled by the Kochava SDK with only the dependency itself needing to be included. The Kochava SDK does not require specific versions of its dependencies however we recommend keeping them up to date whenever possible.
Dependencies —
Add the clouddevsdk.aar file to your project, this can be obtained by contacting your Samsung representative directly.
Permissions —
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
Meta/Facebook:
SDK VERSION NOTE: This feature requires Kochava Android SDK Version 5.1.0 or higher.
If you wish for the SDK to collect and/or make use of the Facebook Attribution ID or Meta Install Referrer, you must add the appropriate manifest entries. Collection is handled by the Kochava SDK with no additional dependencies needing to be included.
NOTE: In order for the Meta Referrer to be collected by the SDK you must have the Facebook Partner configured on the Free App Analytics Dashboard with your Facebook App ID.
Manifest
The following items should be added to the top level of your manifest file.
<queries>
<package android:name="com.facebook.katana" />
<package android:name="com.instagram.android" />
</queries>
Permissions:
The following permissions are split by module and are automatically included with the module. Optional permissions are noted and can be removed if desired using the manifest entry shown.
// Tracker Module
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
// Optionally remove the automatically included Network State permission.
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" tools:node="remove"/> -->
// Network Module
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
// Optionally remove the automatically included Wifi State permission.
<!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" tools:node="remove"/> -->
Minification (ProGuard / R8):
The following minification rules are required when code minification is enabled. They are automatically included when adding the Kochava SDK and typically do not require manual inclusion. If you are experiencing issues after enabling minification you can manually include the rules in your configuration file.
# KochavaCore: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.core**
# KochavaCore: Keep annotations used for json serialization.
-keepattributes Signature
-keepattributes *Annotation*
# KochavaCore: BuildConfig
-keep class com.kochava.core.BuildConfig { *; }
# KochavaCore: Google Instant Apps Collection.
-keep class com.google.android.gms.common.wrappers.InstantApps {
boolean isInstantApp(android.content.Context);
}
# KochavaTracker: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.tracker**
# KochavaTracker: BuildConfig
-keep class com.kochava.tracker.BuildConfig { *; }
# KochavaTracker: Internal SDK
-keep class com.kochava.tracker.modules.internal.Module {
void setController(***);
*** getController();
}
-keep class com.kochava.tracker.Tracker {
static com.kochava.tracker.TrackerApi getInstance();
}
# KochavaTracker: Google ADID Collection.
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
java.lang.String getId();
boolean isLimitAdTrackingEnabled();
}
# KochavaTracker: Google Install Referrer Collection.
-keep class com.android.installreferrer.api.InstallReferrerClient { *; }
-keep class com.android.installreferrer.api.InstallReferrerClient$InstallReferrerResponse { *; }
-keep class com.android.installreferrer.api.InstallReferrerStateListener { *; }
-keep class com.android.installreferrer.api.ReferrerDetails { *; }
# KochavaTracker: Google App Set ID Collection
-keep class com.google.android.gms.appset.AppSet {
com.google.android.gms.appset.AppSetIdClient getClient(android.content.Context);
}
-keep class com.google.android.gms.appset.AppSetIdClient {
com.google.android.gms.tasks.Task getAppSetIdInfo();
}
-keep class com.google.android.gms.appset.AppSetIdInfo {
java.lang.String getId();
int getScope();
}
-keep class com.google.android.gms.tasks.Tasks {
*** await(com.google.android.gms.tasks.Task, long, java.util.concurrent.TimeUnit);
}
# KochavaTracker: Huawei OAID Collection.
-keep class com.huawei.hms.ads.identifier.AdvertisingIdClient {
com.huawei.hms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.huawei.hms.ads.identifier.AdvertisingIdClient$Info {
java.lang.String getId();
boolean isLimitAdTrackingEnabled();
}
# KochavaTracker: Huawei Install Referrer Collection.
-keep class com.huawei.hms.ads.installreferrer.api.InstallReferrerClient { *; }
-keep class com.huawei.hms.ads.installreferrer.api.InstallReferrerClient$InstallReferrerResponse { *; }
-keep class com.huawei.hms.ads.installreferrer.api.InstallReferrerStateListener { *; }
-keep class com.huawei.hms.ads.installreferrer.api.ReferrerDetails { *; }
# KochavaTracker: Samsung Install Referrer Collection.
-keep class com.samsung.android.sdk.sinstallreferrer.api.InstallReferrerClient { *; }
-keep class com.samsung.android.sdk.sinstallreferrer.api.InstallReferrerClient$InstallReferrerResponse { *; }
-keep class com.samsung.android.sdk.sinstallreferrer.api.InstallReferrerStateListener { *; }
-keep class com.samsung.android.sdk.sinstallreferrer.api.ReferrerDetails { *; }
# KochavaTracker: Notifications Enabled Collection.
-keep class androidx.core.app.NotificationManagerCompat {
static androidx.core.app.NotificationManagerCompat from(android.content.Context);
boolean areNotificationsEnabled();
}
# KochavaTracker: Samsung Cloud Game Dev
-keepclassmembers, includecode class
com.samsung.android.game.cloudgame.dev.sdk.* { *;}
# KochavaTrackerDatapointNetwork: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.tracker.datapointnetwork**
# KochavaTrackerDatapointNetwork: BuildConfig
-keep class com.kochava.tracker.datapointnetwork.BuildConfig { *; }
# KochavaTrackerDatapointNetwork: Internal SDK
-keep class com.kochava.tracker.datapointnetwork.internal.DataPointCollectionNetwork {
public <methods>;
}
# KochavaTrackerEngagement: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.tracker.engagement**
# KochavaTrackerEngagement: BuildConfig
-keep class com.kochava.tracker.engagement.BuildConfig { *; }
# KochavaTrackerEngagement: Internal SDK
-keep class com.kochava.tracker.engagement.Engagement {
static com.kochava.tracker.engagement.EngagementApi getInstance();
}
# KochavaTrackerEvents: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.tracker.events**
# KochavaTrackerEvents: BuildConfig
-keep class com.kochava.tracker.events.BuildConfig { *; }
# KochavaTrackerEvents: Internal SDK
-keep class com.kochava.tracker.events.Events {
static com.kochava.tracker.events.EventsApi getInstance();
}
# KochavaTrackerLegacyReferrer: Ignore SDK warnings for missing dependencies.
-dontwarn com.kochava.tracker.legacyreferrer**
# KochavaTrackerLegacyReferrer: BuildConfig
-keep class com.kochava.tracker.legacyreferrer.BuildConfig { *; }
# KochavaTrackerLegacyReferrer: Referrer Receiver
-keep class com.kochava.tracker.legacyreferrer.LegacyReferrerReceiver {
void onReceive(android.content.Context, android.content.Intent);
}
Starting the Tracker
Once you have added the Kochava SDK to your project, the next step is to configure and start the Kochava Tracker in code. Only your App GUID is required to start the tracker with the default settings, which is the case for typical integrations.
We recommend starting the tracker as soon as the application starts, although this can be done later if needed. Starting the tracker as early as possible will ensure it’s started before use, provide more accurate session reporting, and quicker deeplink results.
import 'package:kochava_measurement/kochava_measurement.dart'; KochavaMeasurement.instance.registerAndroidAppGuid("YOUR_ANDROID_APP_GUID"); KochavaMeasurement.instance.registerIosAppGuid("YOUR_IOS_APP_GUID"); KochavaMeasurement.instance.start();
import 'package:kochava_tracker/kochava_tracker.dart'; KochavaTracker.instance.registerAndroidAppGuid("YOUR_ANDROID_APP_GUID"); KochavaTracker.instance.registerIosAppGuid("YOUR_IOS_APP_GUID"); KochavaTracker.instance.start();
Confirm the Integration:
After integrating the SDK or creating a new App GUID, we suggest performing these tests to ensure the SDK has been integrated successfully and is functioning as expected within your app.
Validate the Install:
The SDK will send an install for the app once, after a fresh install. This test ensures the SDK was configured properly and successfully sent the install to Free App Analytics.
- Double check the SDK configuration in code, ensuring the correct App GUID.
- Run the app for approximately 30 seconds, which will allow more than enough time for the SDK to start and send an install to Free App Analytics under typical conditions.
- Wait a minute or two and visit the Install Feed Validation page for your app within the Free App Analytics dashboard, under Apps & Assets > Install Feed Validation. Within that page, look for the Integration Success! message which indicates integration was successful and that Free App Analytics did receive an install from the SDK. At this point you have confirmed a successful SDK integration and can move ahead to Validate Post Install Events below.
- If instead you see a Integration Not Complete! message, wait a few more minutes and refresh the page. After refreshing, if the Integration Not Complete! message persists, double check the following, then repeat this test:
- Correct App GUID is used within SDK code configuration.
- Ensure the SDK configuration and startup code is being reached.
- Ensure the network connection from the test device is not limited behind a firewall or otherwise.
Validate Event Measurement:
If you are measuring user events, you can use this test to ensure the SDK was configured properly and is successfully sending these events to Free App Analytics.
- Double check the SDK configuration in code, ensuring the correct App GUID.
- Double check your event measurement code and ensure it is reachable.
- Launch the app and perform necessary actions within the app to trigger the event(s) you wish to test. After performing these actions, wait 60 seconds to allow more than enough time for the SDK to send these events.
- Wait a minute or two and visit the Event Manager page for your app within the Free App Analytics dashboard, under Apps & Assets > Event Manager. Within that page, ensure the tested event names are displayed here, in which case you have confirmed the SDK is successfully measuring these events.
- If your event names are not displayed here after waiting a few minutes, double check the following, then repeat this test:
- Correct App GUID is used within SDK code configuration.
- Ensure the SDK configuration and startup code is being reached prior to any event code.
- Ensure the SDK event code is being reached.
- Ensure the network connection from the test device is not limited behind a firewall or otherwise.
Where to Go From Here:
Now that you have completed integration you are ready to utilize the many features offered by the Kochava SDK. Continue on to Using the SDK and choose a topic.