App Setup: Integrate with mParticle (Android - Gradle)

Introduction

This article will provide guidance on how to integrate Leanplum in your mobile project using mParticle.

For mParticle Dashboard setup and information on which Leanplum features are supported by mParticle visit https://docs.mparticle.com/#leanplum

 

Android

Adding the integration

The Leanplum Kit requires that you add Leanplum's Maven server to your buildscript:

repositories {
maven { url "http://www.leanplum.com/leanplum-sdks/" }
...
}

 

Add the kit dependency to your app's build.gradle:

dependencies {
compile 'com.mparticle:android-leanplum-kit:4+'
}

 

Follow the mParticle Android SDK quick-start for any additional dependency to be added to your project.

Add the following to your Gradle dependecies necessary to collect the Android Advertisting ID:

compile 'com.google.android.gms:play-services-ads:9.0.0'

 

Add the following in your AndroidManifest Application class as well:

<receiver android:name="com.mparticle.ReferrerReceiver" android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER"/>
</intent-filter>
</receiver>

For Leanplum, you will need Google Play Services in order to use Leanplum Push Services and Leanplum localization services. If you need those services, include also the following in your Gradle dependecies:

compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile 'com.google.android.gms:play-services- location:9.0.0'

Rebuild and launch your app, and verify that you see"LeanplumKit detected" in the output of 'adb logcat'

 

Sample project

Android sample project is available here

 

Leanplum support

The mParticle SDK supported Leanplum features are:

  • Marketing Automation (i.e. In-App messages?)
  • A/B Testing (Messages only?)
  • Analytics (i.e. Tracking Events?)

Along with the mParticle SDK, the Leanplum SDK would also be accessible for using all the other Leanplum features not available out of the box through mParticle (for example setting Variables or Customizing Push Notifications).

Events
To track events through mParticle, the suggested approach is to define a Custom Event. In that way also the parameters can be properly passed to Leanplum.

See the sample: https://github.com/LeanplumTSE/SampleProjects

Map<String, String> eventInfo = new HashMap<String, String>(2);

eventInfo.put("spice", "hot");
eventInfo.put("menu", "weekdays");

MPEvent event = new MPEvent.Builder("Food Order", MParticle.EventType.Transaction)
.duration(100)
.info(eventInfo)
.build();

MParticle.getInstance().logEvent(event);

Event name is in this case "Food Order" string.
The event parameters are passed as argument of info().

 


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