Leanplum's user guides and developer documentation.

Amplitude integration

This integration combines Amplitude's analytics capabilities with Leanplum's marketing automation tools to drive better audience engagement. You'll be able to export Behavioral Cohorts from Amplitude and target them as Saved Segments in Leanplum.

Contact your CSM if you are interested in using this integration.

Setting up the audience integration between Leanplum and Amplitude

  1. From your Leanplum dashboard, select your name in the upper right corner to go to App Settings → Keys & Settings for your app.
  2. Create your Amplitude API Key.
  3. Copy this Amplitude API Key and your App ID.
  1. Go to your Amplitude project → Settings page. Paste your keys in the integration module as shown below and click Save. The status should now change to "Active".

Now, you'll be able to target and engage your Amplitude Behavioral Cohorts using Leanplum campaigns and A/B tests.

Syncing Amplitude cohorts with Leanplum segments

Make sure your users have a unique user ID set in Amplitude

The integration does not support anonymous users, so make sure all users you send to Leanplum have unique User IDs set in Amplitude. The integration will still work, but anonymous users will not be synced.

  1. Create a Behavioral Cohort in Amplitude
  2. To export to leanplum, click Export and select Leanplum as your destination. Now you can engage the users in your Behavioral Cohort through Leanplum.

Cohort names must be < 150 characters

The name of your Behavioral Cohorts in Amplitude must be 150 characters or less for them to be exportable to Leanplum.

You can configure your Amplitude Behavioral Cohorts to sync with Leanplum hourly or daily. You can also sync them manually as needed.

Once you sync your Amplitude Behavioral Cohort with Leanplum, it may take up to 20 minutes for the Saved Segment to populate in Leanplum.

Leanplum will create missing users

If there are users in your Amplitude cohort who do not exist in Leanplum, they will be created as new users. However, you may not be able to target them initially, because they will not have a device or email address on record.

Using Amplitude cohorts in Leanplum

Once you sync your Behavioral Cohorts, they will be available as Saved Segments in Leanplum. You'll be able to target these users with messaging campaigns, A/B tests, and more.

To target users in an Amplitude cohort, go to the + Segment dropdown to select your audience, then hover over Saved Segments to see you Amplitude Cohorts.

Export events from Leanplum to Amplitude

You can configure your app to automatically export the following Leanplum events to your Amplitude project. All events will be tagged with the User ID and Device ID associated with the user at the time of the event.

Channel type
Events

Push notification

Sent, Open, Held Back

Email

Sent, Deferred, Delivered, Bounce, Open, Click, Marked as spam, Dropped, Unsubscribe, Held Back

In-app message

By template:
All templates — View, held back
Center Popup, Confirm, Interstitial — Accept
Rich interstitial — Select Button 1, Select Button 2
Satisfaction Survey — Submit
Banner — Select

A/B test

Impression event

Note that you can't specify which events trigger postbacks, however, you can ignore any events you aren't interested in in Amplitude.

Set up Postbacks to export events to Amplitude

Leanplum uses Postbacks to send events to Amplitude. To set up your event export using Postbacks and the Leanplum API:`

  1. Go to your Leanplum App Settings → Keys & Settings.
  2. Copy the App ID and Data Export key, and your Amplitude key from Key's and settings
  3. Copy this command and paste it into a text editor.
curl -X POST \
  'https://www.leanplum.com/api?action=addPostback' \
  -H 'Content-Type: application/json' \
  -d '{
	"appId": "LP_APP_ID",
	"clientKey": "LP_KEY",
	"apiVersion": "1.0.6",
	"type": "messageEvents",
	"channels": ["Push Notification", "Email", "In-app Message"],
	"postbackUrl":"https://api.amplitude.com/httpapi?api_key=AMPLITUDE_KEY&event=[{\"user_id\":\"{{User ID}}\", \"device_id\":\"{{Device ID}}\", \"event_type\":\"(Leanplum) Message {{Message event}}\", \"event_properties\":{\"Message ID\":\"{{Message ID}}\", \"Channel\":\"{{Message channel}}\", \"Template\":\"{{Template name}}\"}, \"time\":{{Trigger time}}}]"
}'


curl -X POST \
  'https://www.leanplum.com/api?action=addPostback' \	
  -H 'Content-Type: application/json' \
  -d '{
	"appId": "LP_APP_ID",
	"clientKey": "LP_KEY",
	"apiVersion": "1.0.6",
	"type": "abTestEvents",
	"channels": ["Push Notification", "Email", "In-app Message"],
	"postbackUrl":"https://api.amplitude.com/httpapi?api_key=AMPLITUDE_KEY&event=[{\"user_id\":\"{{User ID}}\", \"device_id\":\"{{Device ID}}\", \"event_type\":\"(Leanplum) A/B Test Impression\", \"event_properties\":{\"AB Test ID\":\"{{AB test ID}}\", \"Variant ID\":\"{{Variant ID}}\"}, \"time\":{{Trigger time}}}]"
}'

Replace the placeholders with the keys you copied. (i.e., replace LP_APP_ID with your Leanplum App ID, LP_KEY with the Data Export key, and AMPLITUDE_KEY with the Amplitude project API key you got from Amplitude.)

  1. Save the file and close it.

This file contains a curl command that, when executed, will configure your app with 2 Postbacks. One to export all Message events and one to export the A/B test enter event. You can run this curl command in an HTTP client, such as Postman, or by copying the command and pasting it into a terminal.

You can include or remove any of the event properties provided in the postbackUrl, depending on what information you want to send to Amplitude:

Possible values for all postback events:

  • User ID — The user ID that triggered the event.
  • Device ID — The device ID that triggered the event.
  • Trigger time — The time in milliseconds at which the postback was triggered. The time can be in the past if the triggering event occurred in the past.

Possible values for messages:

  • Message ID — The message ID that triggered the postback.
  • Message event — The message event that triggered the postback (e.g. Send, Open).
  • Message channel — The channel of the message (push, email, or in-app message).
  • Template name — The template name of the in-app message. Returns an empty string for non-in-app messages.
  • Parameters — All the parameters associated with the event when it is triggered. For example, an email’s Click event will include the URL clicked and the index of the URL. parameters are in JSON format, and all parameter values are URL encoded.

Possible A/B test event values (sent when the A/B test impression event occurs):

  • AB test ID — The ID of the A/B test the user entered into.
  • Variant ID — The ID of the variant group the user was sorted into.

Verify your events are showing up in Amplitude

Send yourself a test message in Leanplum to ensure the events are showing up in your Amplitude profile's Event Stream. See more on testing and previewing messages in Leanplum.

Amplitude integration


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.