Segment Integration : Introduction

Setup guide for using MoEngage with Segment

If you are already using Segment for tracking data then the Segment - MoEngage Integration makes it extremely easy for you to send your event and attribute data to MoEngage.

Once you've tracked your data through Segment's source libraries, Segment will translate this and route your data to MoEngage in the format MoEngage understands so that you can save some of your engineering efforts for using MoEngage.
Learn more about how to use MoEngage with Segment.

Integration Components

The MoEngage <> Segment Integration supports the following -

Segment -> MoEngage Data Integration:
With this integration mode, Segment will forward the data collected from your sources to MoEngage automatically. The data points that will be forwarded to MoEngage are Events and User Properties.

Segment <> MoEngage integration supports two different connection modes for forwarding the data from Segment to MoEngage. The most preferred one is the device mode integration which will enable all moengage capabilities for your mobile app and also forward all data to moengage directly from your mobile app. For sending offline data to moengage, we recommend using the cloud mode integration.
More details for both are in the following sections.

MoEngage -> Segment Data Export Integration:
With this integration, you can forward the data collected by MoEngage like the Campaign Events, MoEngage derived attributes back to Segment and then forward it to all connected destinations.
More details are available in the last section of this article.

Getting Started

Segment as a platform supports 2 different connection modes -

Device Mode
This is the preferred connection mode for using Moengage with Segment. With the device mode connection, segment will forward all track and identify requests to MoEngage directly via the user's device.
Here, your app will make separate requests to Segment and MoEngage without you having to send data to MoEngage explicitly.

Please ensure that you are integrating the MoEngage + Segment bundle if you want to use Device Mode on Android and iOS and ensure that you are selecting Device Mode connection for your website data. The connection mode is by default Device Mode on Android and iOS.

Connecting MoEngage Destination for Android and iOS Source -

After saving the MoEngage destination, enter your MoEngage App Id which is available on MoEngage Dashboard -> Settings -> App -> General here -

Connecting MoEngage Destination for JS Source -
(Recommended Connection Mode is Device Mode)

After saving the MoEngage destination, enter your MoEngage App Id which is available on MoEngage Dashboard -> Settings -> App -> General here -

For using the device mode connection and leveraging all MoEngage capabilities, you would need to follow the integration steps mentioned below -

Cloud Mode
Cloud Mode Connection is used in the below cases -

  1. You would need the Cloud Mode connection if you want to forward data to MoEngage generated by Segment's server side sources.

  2. For your Javascript source and MoEngage destination, you will see an option on your Segment dashboard to select the connection Mode. If you choose "Cloud Mode" here, Segment will forward all track and identify requests to MoEngage via server to server integration if the connection to MoEngage destination is via Cloud Mode.

  3. If you establish a connection between your Android / iOS source and MoEngage destination and MoEngage + Segment code is not bundled on a device, then Segment will send this data to MoEngage via Cloud Mode connection automatically.

You can refer Segment documentation for more information on Segment sources, MoEngage destination and supported connection modes.

Configuration on Segment

To setup MoEngage do the following:

  1. First get your key (AppID) from MoEngage dashboard.
  2. Go to Segment dashboard, then 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.
  6. Make sure the Connection Mode is set to Device Mode. This is required in order to make use of features like push notification and in-app feature of MoEngage SDK. You would also need to update your app with client side integration.

These new settings will take up to an hour to propagate to all of your existing users. For new users it’ll be instantaneous!

Please note that Segment-MoEngage Integration is a bundled integration and requires client side integration.

APP ID : Get the App Id from your MoEngage Dashboard: Settings -> App -> General
Enable Debug Logging : Switch it on if you want to enable debug logs. Switching it on will flow your data to TEST environment in MoEngage.
Connection Mode : You will see this option only for the JavaScript source.
For Android, iOS sources, the default connection mode is Device mode.
For Server side sources, default connection mode is Cloud mode.

Which connection mode to choose?

To use MoEngage with Segment, we strongly recommend you to go ahead with the Device Mode connection as all our capabilities are supported with Device Mode.

For sending data to MoEngage via you server side sources, you would always need to use Cloud Mode.

While MoEngage ingests data sent via Segment Cloud Mode connection, there are a few limitations with this approach as of now -

  1. For using MoEngage Push Notifications, InApp Messaging - you would need to install the MoEngage SDKs separately.

  2. As of now, MoEngage only accepts data via Cloud Mode if the User Id is present. If the User Id is not present, the data will be rejected by MoEngage Cloud Destination.

  3. If connection mode is cloud mode, you cannot use MoEngage functionalities like Real Time Triggers, On-site Messaging and Smart In-App Messaging.

Integration for Device Mode

Below are the steps to get started with Device Mode Configuration -

  1. Add the moengage dependency as per the source.
  2. Follow the documentation mentioned below -


Integration for Cloud Mode

For your server side sources, Cloud Mode is the default connection mode and you do not need to configure anything here.

There are some limitations while using Cloud Mode Integration -

  1. Segment will transform all your attributes (properties) from camelCase to snake_case before sending this data to MoEngage (only via Cloud Mode). This may result in you seeing multiple attributes listed on your MoEngage dashboard.
    Such transformation does not happen when you are on Device Mode.

  2. MoEngage can only track data of logged in users via Cloud Mode. Logged in users are all users for whom a user_id is available in segment. For users and requests without a user_id, MoEngage will reject the requests.

MoEngage -> Segment Data Export Integration

With the data export integration, MoEngage will forward the campaign data from MoEngage to Segment.

To setup this integration, follow the below steps -

-- Add an HTTP source in Segment -
-- Once you have setup HTTP source in Segment, please get the data flow enabled by writing to your
MoEngage account manager or to our support team at [email protected]
-- Please include the Write key of your HTTP source in your email to MoEngage team as we would
need this to authenticate our event requests to Segment.

Once we have enabled the data export integration from MoEngage, you should start seeing the campaign events generated by MoEngage in Segment and all destinations connected to your HTTP source in Segment.

The data points sent to Segment from MoEngage are available here -> Campaign Interaction Events.