Integrate SDK
This guide provides step-by-step instructions to initialize the AppTrove SDK in your Android application. It covers retrieving your SDK key, setting up the Application class, and configuring the SDK for different environments.
Initialization
Step 1: Retrieve Your SDK Key
- Log in to your Trackier Panel
- Select your application
- Navigate to SDK Integration in the dashboard
- Copy the SDK Key displayed
Step 2: Initialize the SDK
We recommend initializing the SDK inside your app's global Application class. This ensures proper initialization in all scenarios, including deep linking.
2.1 Set Up the Application Class
If your project doesn't have an Application class:
- Create a new class that extends
Application
- Open your
AndroidManifest.xml
file - Add the
android:name
attribute to the<application>
tag:
<application
android:name=".MainApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
<!-- Other configuration -->
</application>
2.2 Initialize the AppTrove SDK
Add the initialization code in your Application class's onCreate()
method:
- Java
- Kotlin
import com.trackier.sdk.TrackierSDK;
import com.trackier.sdk.TrackierSDKConfig;
public class MainApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
final String TR_SDK_KEY = "XXXXXXX-XXXX-XXXX-80e3-5938fadff"; // Your SDK key
TrackierSDKConfig sdkConfig = new TrackierSDKConfig(
this, // Application context
TR_SDK_KEY, // Your AppTrove SDK key
"development" // Environment: "development", "testing", or "production"
);
TrackierSDK.initialize(sdkConfig);
}
}
import android.app.Application
import com.trackier.sdk.TrackierSDK
import com.trackier.sdk.TrackierSDKConfig
class MainApplication : Application() {
override fun onCreate() {
super.onCreate()
val TR_SDK_KEY = "xxxx-xx-4505-bc8b-xx" // Your SDK key
val sdkConfig = TrackierSDKConfig(
this, // Application context
TR_SDK_KEY, // Your AppTrove SDK key
"development" // Environment: "development", "testing", or "production"
)
TrackierSDK.initialize(sdkConfig)
}
}
Using the wrong SDK key will impact all traffic sent from the SDK and cause attribution/reporting issues.
Step 3: Configure for Production
When ready to release your app:
- Change the environment parameter to
"production"
- Update your log level as needed
Example for production:
TrackierSDKConfig sdkConfig = new TrackierSDKConfig(this, TR_SDK_KEY, "production");
val sdkConfig = TrackierSDKConfig(this, TR_SDK_KEY, "production")
Next Steps
After completing the initialization:
- Verify your integration by checking for incoming events in the Trackier dashboard
- Implement event tracking as needed (refer to the [Event Tracking Guide])
- For assistance, contact Trackier support at support@trackier.com
For complete documentation, visit the Trackier Developer Portal.