App Setup: How to integrate Segment/Leanplum [Android]


To install the Leanplum SDK through Segment, make sure to follow the setup instructions in Segment's documentation.

In addition to the standard Segment integration dependencies, the following also needs to be added in order to get the Leanplum SDK:

compile 'com.leanplum.segment:LeanplumIntegration:+'



This is an example of how to use Leanplum once is integrated through Segment. 

Make sure to place the initialization part in your project Application class:

private static final String SEGMENT_WRITE_KEY = " ... ";

Analytics analytics = new Analytics
  .Builder(getApplicationContext(), SEGMENT_WRITE_KEY)

Now you can use Segment as you are used to, e.g.:

analytics.track(" ... ", ... );

Note: There is no need to explicitly call Leanplum.start, as it is called within the LeanplumIntegration.

In addition to that you can also use the advanced features of Leanplum. Once the Leanplum SDK is successfully registered, Segement executes a callback:

    new Analytics.Callback() {
      public void onReady(Object instance) {
        Leanplum.addVariablesChangedHandler( ... );

An Android sample project is available here.

Was this article helpful?
Have more questions? Submit a request