SDK
HomePromoteAnalyzeDevelopResources
4.5.0
4.5.0
  • SDK Overview
    • Tracking Documentation
      • Android
      • iOS & SKAdNetwork
      • Retargeting
    • Predefined Events
    • Find your justtrack token
  • Android
    • Overview
      • Retargeting users
      • Revenue
      • UserEvent API
      • Demo
      • Changelog
    • Set up the SDK
    • Send user events
    • Get the justtrack user ID
    • Get an attribution
    • Get an advertiser and test group ID
    • Integrate third-party SDKs
  • iOS
    • Overview
      • Track sessions
      • UserEvent API
      • Changelog
    • Set up the SDK
    • Send user events
    • Get the justtrack user ID
    • Get an attribution
    • Get an advertiser and test group ID
    • Integrate third-party SDKs
    • Request tracking authorization
  • Unity
    • Overview
      • Forward Ad Impressions
      • UserEvent API
      • Changelog
    • Install the SDK
    • Install the dependencies
    • Add the prefab
    • Send user events
    • Get a justtrack user ID
    • Get an attribution
    • Get an advertiser and test group Id
    • Provide your own user Id
    • Integrate third-party SDKs
    • Forward in-app purchases
    • Get an affiliate link
    • Configure your iOS application
Powered by GitBook
On this page
  • Add the SDK
  • Copy your API Token
  • Instantiate the SDK
  • Shutdown the SDK
  1. Android

Set up the SDK

The justtrack SDK offers extensive tracking capabilities for attribution, events, and various other functionalities within your Android application. In this guide, you'll learn to:

dependencies {
    implementation "io.justtrack:justtrack-android-sdk:4.5.0"
}
dependencies {
    implementation("io.justtrack:justtrack-android-sdk:4.5.0")
}
  • Add the justtrack SDK to your app

  • Copy your API token

  • Instantiate a JustTrackSdk object

  • Shutdown the SDK instance

Add the SDK

In your project-level build.gradle, add the following repository to allprojects:

allprojects {
    repositories {
        maven {
            url "https://sdk.justtrack.io/maven"
        }
    }
}
allprojects {
    repositories {
        maven {
            url = uri("https://sdk.justtrack.io/maven")
        }
    }
}

Then, in your module-level build.gradle, add the following dependency to your dependencies:

dependencies {
    implementation "io.justtrack:justtrack-android-sdk:4.5.0"
}
dependencies {
    implementation("io.justtrack:justtrack-android-sdk:4.5.0")
}

Copy your API Token

Store your token as a constant called JUSTTRACK_SDK_API_TOKEN in your BuildConfig file:

android {
    defaultConfig {
        buildConfigField "String", "JUSTTRACK_SDK_API_TOKEN", '"prod-c6654a0ae88b2f21111b9d69b4539fb1186de983f0ad826f0febaf28e3e3b7ed"'
    }
}
android {
    defaultConfig {
        buildConfigField("String", "JUSTTRACK_SDK_API_TOKEN", "\"prod-c6654a0ae88b2f21111b9d69b4539fb1186de983f0ad826f0febaf28e3e3b7ed\"")
    }
}

Instantiate the SDK

In your main activity class, or the class where you want to use the SDK, create an instance variable, SDK, for the JustTrackSdk.

public class MainActivity extends SomeActivity {
    private JustTrackSdk sdk = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // ...
        sdk = new JustTrackSdkBuilder(this, BuildConfig.JUSTTRACK_SDK_API_TOKEN).build();
    }
}
class MainActivity : Activity() {
    private lateinit var sdk: JustTrackSdk

    override fun onCreate(savedInstanceState: Bundle?) {
        // ...
        sdk = JustTrackSdkBuilder(this, BuildConfig.JUSTTRACK_SDK_API_TOKEN).build()
    }
}

If you define your own application class, it must extend android.app.Application.

Shutdown the SDK

When your app terminates, you need to unregister listeners and tear down session tracking.

First, in onDestroy(), call your SDK object's shutdown() method. Then, set the SDK to null because it will no longer be used:

@Override
protected void onDestroy() {
    sdk.shutdown();
    sdk = null;
    // ...
    super.onDestroy();
}
override fun onDestroy() {
    sdk.shutdown()
    sdk = null
    // ...
    super.onDestroy()
}

Last updated 1 year ago

Before integrating the justtrack SDK into your app, you need to obtain an API token. Follow our guide to .

find your token