MoEngage Docs

Android Integration

Integrating MoEngage with Segment in Android

SDK Installation

Add segment's bundled library dependency in the app's build.gradle

If you are updating from 2.x.x, please check notes here before updating.

dependencies {
    implementation ''
    implementation('com.moengage:moengage-segment-integration:3.3.00') {
        transitive = true

Setup MoEngage

To setup MoEngage do the following :

  1. First get your key(AppID) from MoEngage dashboard.
  2. Go to Segment dashboard, go to Integrations and select MoEngage.
  3. Enable MoEngage Integration.
  4. Go to MoEngage Settings and enter the MoEngage AppID, obtained in Step1.
  5. Save the changes.

Initializing Segment and MoEngage

In the Application subclass, initialize Segment and tell segment that you are using MoEngage bundled with Segment. Add the following code snippet in your Application class.

public class SegmentDemoApplication extends Application {
  public void onCreate() {
    Analytics analytics = new Analytics.Builder(getApplicationContext(),
            "writeKey")//use your own write key
    .logLevel(Analytics.LogLevel.VERBOSE)// should be added only in debug builds. Make sure this
    // is removed before a signed apk is generated.
    .use(MoEngageIntegration.FACTORY)//enable MoEngage integration

    Analytics.setSingletonInstance(analytics);//recommended as creating a new instance every time
    // is expensive in terms of resources used
// this is the instance of the application class and "XXXXXXXXXXX" is the APP ID from the dashboard.
MoEngage moEngage = new MoEngage.Builder(this, "XXXXXXXXXXX")

Tracking User Attributes

Analytics.with(MainActivity.this).identify("user attributes", new Traits().putFirstName("Umang").putGender("Male"),  null);

To know more about tracking user attributes you can refer this link

Tracking Events using Segment

Analytics.with(MainActivity.this).track("Email button Click", new Properties().putValue("email", "opened"));

To know more about tracking events you can refer this link

Tracking Date attributes via Segment SDK

If you are tracking date as a user attribute or event attribute it needs to be tracked in ISO 8601 Format. Supported formats:


Configuring MoEngage SDK

For configuring the MoEngage SDK further refer to this link.

Sample Implementation

Further refer to this github repository for sample implementation