Skip navigation links

Package com.kochava.base

KochavaTracker (Android)

See: Description

Package com.kochava.base Description

KochavaTracker (Android)

A lightweight and easy to integrate SDK written in Java, providing first-class integration with Kochava’s installation attribution and analytics platform.

Platforms

Requirements

Integration

1. Add the SDK into your project.

You have the option of downloading the SDK either using Maven, or through the direct download of the AAR file.

Using Maven

Add the Kochava Maven repository to your root-level build.gradle file.

 
 allprojects {
     // ...
     repositories {
         // ...
         maven {url "http://kochava.bintray.com/maven"}
     }
 }
 
 

Add the Kochava SDK to your module level build.gradle file. Replace "x.y.z" with the version obtained from the Download Badge above.

 
 dependencies {
     // ...
     compile 'com.kochava.base:Tracker:x.y.z'
 }
 
 

Direct Download

Download the AAR file from the Download Badge above and either add it directly or extract the JAR file and other resources from it and add them individually.

2. Add Dependencies

Dependencies are added alongside the Kochava SDK in your module level build.gradle file.

 
 dependencies {

     //Required: Google Play Services Base (If publishing to the Google Play Store)
     compile 'com.google.android.gms:play-services-base:11.6.0'

     //Required: Install Referrer (If publishing to the Google Play Store)
     compile 'com.android.installreferrer:installreferrer:1.0'

     //Optional: Location Collection. Note: This feature must also be enabled server side before collection will occur.
     compile 'com.google.android.gms:play-services-location:11.6.0'

     //Optional: Instant App Status Collection
     compile 'com.google.android.instantapps:instantapps:1.1.0'
 }
 
 

3. Add Permissions

Permissions are added to the top level of the AndroidManifest.xml file. Required and Recommended permissions are automatically added when using the AAR. If a recommended permission is unwanted it can be removed using the tools:node="remove" manifest merge feature.

Note Ensure you are compliant with the terms and requirements of the publishing app store regarding sensitive permissions such as GET_ACCOUNTS.

 
 //Required:
 <uses-permission android:name="android.permission.INTERNET" />

 //Recommended: Wifi and Network state Collection
 <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

 //Optional: Paired and Connected Bluetooth Device Collection
 <uses-permission android:name="android.permission.BLUETOOTH"/>

 //Optional: Location Collection. Note: This feature must also be enabled server side before collection will occur.
 <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
 <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

 //Optional: Email Collection. Note: This feature must also be enabled on the Kochava dashboard before collection will occur.
 <uses-permission android:name="android.permission.GET_ACCOUNTS" />
 
 

4. Broadcast Receiver

Deprecated. As of 3.3.0, because Google has introduced a new way of retrieving the Install Referrer. Add the install referrer library listed in dependencies to ensure collection with the new API. You should also continue using the broadcast receiver until Google completes the transition.

The Kochava Tracker features an AAR included broadcast receiver that listens for the INSTALL_REFERRER broadcast action. If the Kochava Tracker broadcast receiver is the only receiver for that action in your app no further action is required. Otherwise refer to the ReferralReceiver reference for advanced configuration instructions.

5. Configure a Tracker

To configure the Tracker, first create a Tracker.Configuration object, and then perform the configuration using the configuration method Tracker.configure(com.kochava.base.Tracker.Configuration). It is recommended that you call this in your Application.onCreate method.

Note If you are doing an advanced configuration such as in a multiple process app then read the advanced usage section in Tracker.Configuration.

 
 import android.app.Application;
 import com.kochava.base.Tracker;
 import com.kochava.base.Tracker.Configuration;

 public class MyApplication extends Application {

     @Override
     public void onCreate() {
         super.onCreate();

         Tracker.configure(new Configuration(getApplicationContext())
             .setAppGuid("_YOUR_KOCHAVA_APP_GUID_")
             .setLogLevel(Tracker.LOG_LEVEL_INFO)
         );
     }
 }
 
 

Using the SDK

Sending Events

More than basic analytics, the events you send to Kochava are associated with your install attribution data, so that you can understand how the users who came to you through a particular ad went on to use the various features within your app. For more information, refer to Tracker.Event.

 
 Tracker.sendEvent(new Event(Tracker.EVENT_TYPE_PURCHASE)
     .setName("Gold Token")
     .setPrice(1.99)
     .setCurrency("USD")
 );
 
 

Setting Identity Link

You can link additional identifying information with an install, where it can be integrated with your analytics. For more information see Tracker.setIdentityLink(com.kochava.base.Tracker.IdentityLink).

Getting Attribution

You can retrieve Kochava’s attribution information within your app. For more information see Tracker.getAttribution().

Getting the Device ID

You can get the unique device identifier used by the tracker. For more information see Tracker.getDeviceId().

Adjusting the Log Level

You can specify the types of entries which the tracker prints to the log. For more information see Tracker.LogLevel.

Push Notifications

If the desired app has been configured to use the Kochava Push Notification service, you can use the SDK to send push tokens and push open events. For more information refer to our Push Notifications support documentation.

Intelligent Consent Management

When intelligent consent management is enabled and configured within your Kochava dashboard, the SDK will indicate when the user should be prompted for consent. It will also not gather, persist, or transmit data which requires consent unless consent has been granted. For more information see Intelligent Consent Management. For code-level integration see Tracker.Configuration.setIntelligentConsentManagement(boolean).

Reference

For detailed information about the available classes and their associated resources, see documents below.

See Also:
Getting Started Guide, Testing an Integration with Kochava, Event Examples, Other Platforms, Google Play Services Setup, Android Permissions
Skip navigation links