MoEngage Docs

Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Android Integration

Integrating MoEngage with Segment in Android

SDK Installation

Follow these steps to install the MoEngage SDK into your Android app.

com.google.android.gms:play-services-gcm:8.1.0

MoEngage depends on play services location library for Geofencing and other location related information. Please add the location library if you need to use Geofencing.

**MoEngage checks for location permission and if it is available, then gets and sets geofences

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.

Adding Dependency

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

dependencies {
    compile 'com.segment.analytics.android:analytics:+'
    compile('com.moengage:moengage-segment-integration:2.1.00') {
        transitive = true
    }
}

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 {
  @Override
  public void onCreate() {
    super.onCreate();
    Analytics analytics = new Analytics.Builder(getApplicationContext(),
            "xMESvGwLPeCwurQ4yY9fv3iaHlredqVC")//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
    .build();

    Analytics.setSingletonInstance(analytics);//recommended as creating a new instance every time
    // is expensive in terms of resources used

  }
}

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

Configuring MoEngage SDK

For configuring the MoEngage SDK further refer to this link.

Sample Implementation

Further refer to this github repository for sample implementation

Android Integration

Integrating MoEngage with Segment in Android