RudderStack is a customer data pipeline tool for collecting, routing and processing data from your websites, apps, cloud tools, and data warehouse.
More information on RudderStack can be found here.
The RudderStack Android SDK allows you to track event data from your Android apps. After integrating this SDK, you will also be able to send the event data to your preferred destinations such as Google Analytics, Amplitude, and more.
- Add these lines to your
app/build.gradle
repositories {
maven { url "https://dl.bintray.com/rudderstack/rudderstack" }
}
- Add the dependency under
dependencies
implementation 'com.rudderstack.android.sdk:core:1.0.10'
val rudderClient: RudderClient = RudderClient.getInstance(
this,
<WRITE_KEY>,
RudderConfig.Builder()
.withDataPlaneUrl(<DATA_PLANE_URL>)
.build()
)
or (compatible with existing Segment code)
RudderClient.Builder builder = new RudderClient.Builder(this, <WRITE_KEY>);
RudderClient.setSingletonInstance(builder.build());
rudderClient.track(
RudderMessageBuilder()
.setEventName("some_custom_event")
.setProperty(
TrackPropertyBuilder()
.setCategory("test_category")
.build()
)
.setUserId("test_user_id")
)
or (compatible with existing Segment instrumentation code)
String customEvent = "some_custom_event";
String propertyKey = "some_property_key";
String propertyValue = "some_property_value";
RudderClient.with(this).track(
customEvent,
new RudderProperty().putValue(propertyKey, propertyValue)
);
For more detailed documentation check the documentation page.
For device mode destinations, you can register callbacks, which will be executed after the native SDK has been successfully initialized. Use the onIntegrationReady
method to register your callback.
The following snippet shows an example:
rudderClient.onIntegrationReady("Lotame") {
var nativeSDK = (it as LotameIntegration)
// your custom code
}
The variable it
contains the intialized nativeSDK object.
Note: The method onIntegrationReady
accepts two arguments- the integration name(eg. "Lotame") and the callback.
Registering Lotame's onSync callback shows one more example of registering a callback using onIntegrationReady
.
If you come across any issues while configuring or using the RudderStack Android SDK, please feel free to start a conversation on our Slack channel. We will be happy to help you.