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:
- Add the justtrack SDK to your app
- Copy your API token
- Instantiate a
JustTrackSdk
object
Add the SDK
In your settings.gradle
, add our Maven repository:
- Kotlin
- Groovy
dependencyResolutionManagement {
repositories {
// .. your other repositories
maven(url = "https://sdk.justtrack.io/maven")
}
}
dependencyResolutionManagement {
repositories {
// .. your other repositories
maven {
url "https://sdk.justtrack.io/maven"
}
}
}
Then, in your module-level build.gradle
, add the following dependency to your dependencies
:
- Kotlin
- Groovy
dependencies {
implementation("io.justtrack:justtrack-android-sdk:5.0.1")
}
dependencies {
implementation "io.justtrack:justtrack-android-sdk:5.0.1"
}
Please view the latest version here.
Copy your API token
Before integrating the justtrack SDK into your app, you need to obtain an API token. Follow our guide to find your token.
Instantiate the SDK
The SDK consists of a handful of (public) classes and interfaces you can interact with. The main interface is JustTrackSdk
which allows you to attribute the current user, send notifications to the backend or record user events. To create an instance of the SDK you have to invoke the JustTrackSdkBuilder
class. Instantiating the SDK could look like this:
- Java
- Kotlin
public class MainActivity extends Activity {
private JustTrackSdk sdk = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
// ...
sdk = new JustTrackSdkBuilder(this, "...your API token").build();
}
}
class MainActivity : Activity() {
private lateinit var sdk: JustTrackSdk
override fun onCreate(savedInstanceState: Bundle?) {
// ...
sdk = JustTrackSdkBuilder(this, "...your API token").build()
}
}