Segment makes it easy to send/receive your user data/events to/from Analytics for Android only supports any Android device running API 14 (Android 4.0) and higher.

Getting Started

To integrate Segment with follow the below steps:

Step 1: Install the Library

The recommended way to install the library for Android is with a build system like Gradle. This makes it dead simple to upgrade versions and add destinations. The library is distributed via Maven Central. Simply add the analytics module to your build.gradle:

dependencies {
compile ''
implementation 'ai.customfit:customfit-android-client:1.0.0'

And also you need to make the following entries in the build.gradle of the project :

allprojects {
repositories {
maven {
url ""

Step 2: Initialize the Client

We recommend initializing the client in your Application subclass.

// Create an analytics client with the given context and Segment write key.
Analytics analytics = new Analytics.Builder(getApplication(), YOUR_WRITE_KEY)
.trackApplicationLifecycleEvents() // Enable this to record certain application events automatically!
.recordScreenViews() // Enable this to record screen views automatically!
// Set the initialized instance as a globally accessible instance.

Once you have initialized an Analytics client, you also need to inform about the user, just by sending the user customer id

CFUser user = new CFUser.Builder("user_customer_id")
CustomFit.init(getApplication(), "CLIENT_KEY", user, WAIT_TIME);

Step 3: Add Permissions

Ensure that the necessary permissions are declared in your application’s AndroidManifest.xml.


identify lets you tie a user to their actions(events) and record traits(properties) about them. It includes a unique User ID and any optional traits you know about them.

We recommend calling identify a single time when the user’s account is first created, and only identifying again later when their traits(properties) change.

Example identify call:

Traits traits = new Traits();


track lets you record the actions your users perform. Every action triggers what we call an “event”, which can also have associated properties.

Example track call:

analytics.track("Product Added", new Properties()
.putValue("cart_id", "skdjsidjsdkdj29j")
.putValue("product_id", "507f1f77bcf86cd799439011")
.putValue("sku", "G-32")
.putValue("category", "Games")
.putValue("name", "Monopoly: 3rd Edition")
.putValue("brand", "Hasbro")
.putValue("variant", "200 pieces")
.putValue("price", 18.99)
.putValue("quantity", 1)
.putValue("coupon", "MAYDEALS")
.putValue("position", 3)
.putValue("url", "")
.putValue("image_url", ""));

In order to configure your app to get the config values please visit here. And also to get the near real-time updates you need to register the configs. To know how to register the configs please visit here.