MoEngage
Step-by-step guide to set up MoEngage as a destination in RudderStack
Last updated
Was this helpful?
Step-by-step guide to set up MoEngage as a destination in RudderStack
Last updated
Was this helpful?
MoEngage is an intelligent customer engagement platform that allows you to effectively engage with your customers throughout their product journey. It allows you to track and map your customer life-cycle across various touchpoints, and optimize their customer experience at each stage.
With MoEngage, you can effectively deliver personalized communication to your customers and thereby increase overall customer engagement and audience retention.
RudderStack now supports MoEngage as a destination to seamlessly send your event data in real-time.
Find the open-source transformer code for this destination in our GitHub repo.
Before configuring your source and destination on the RudderStack, please verify if the source platform is supported by MoEngage, by referring to the table below:
Connection Mode
Web
Mobile
Server
Device Mode
Supported
Supported
-
Cloud Mode
Supported
Supported
Supported
To know more about the difference between Cloud mode and Device mode in RudderStack, read the RudderStack connection modes guide.
Once you have confirmed that the platform supports sending events to MoEngage, perform the steps below:
From your RudderStack dashboard, add the source. From the list of destinations, select MoEngage.
Give a name to the destination and click on Next. You should then see the following screen:
In the Connection Settings on the RudderStack dashboard, please enter the MoEngage API ID, API Key, and Region, as shown above.
By turning on the native SDK switch under Android SDK Settings on the RudderStack dashboard you can enable Rudder Stack Device Mode for Android Sources. Similarly for Web Under Web SDK Settings and IOS under iOS SDK Settings.
Choose EU
in the Region
field to send your event data to the MoEngage Europe server. To send your event data to the MoEngage India server, choose IND
.
iOS Android React Native Follow these steps to add MoEngage to your iOS project:
Go to your Podfile
and add the Rudder-Moengage
extension:
After adding the dependency followed by pod install
, you can add the imports to your AppDelegate.m
file, as shown:
Finally, change the initialization of your RudderClient
, as shown:
Follow these steps to add MoEngage to your Android project:
Open your app/build.gradle
(Module: app) file and add the following:
Add the following under the dependencies section:
Also, add the below plugin after buildscript
:
Open your build.gradle
(Module: Project) file and add the following in the buildscript
dependencies:
Initialize the RudderStack SDK in the Application
class's onCreate()
method, as shown:
Initialize the MoEngage SDK in the Application
class's onCreate()
method:
Follow these steps to add MoEngage to your React Native project:
Add the RudderStack-MoEngage module to your app by running the following command:
Import the above module and add it to your SDK initialization, as shown:
Add the following under the dependencies section of the android/app/build.gradle
(Module: app) file in the Android folder of your React Native project:
In the android/build.gradle
(Module: Project) file, add the following:
Add the following in the buildscript
dependencies in android/build.gradle
(Module: Project) file:
Also, add the following plugin at the top of android/app/build.gradle
(Module: app):
Initialize the MoEngage SDK in the Application
class' onCreate()
method, as shown:
To identify a user to MoEngage, you need to call the identify
API.
For information on the identify
call, please refer to our RudderStack API Specification guide.
MoEngage needs a unique identifier to identify a user. So, if you provide userId
in your identify
call, RudderStack passes it as that customer_id
. Otherwise, it sends an anonymousId
if a userId
is not present.
You can also create a new user property or update existing user properties of the users using the identify
API.
A sample identify call is as shown:
Identify api will be used to Login the user into MoEngage in Device Mode
The following property names are reserved by MoEngage:
name
first_name
last_name
email
age
gender
mobile
transactions
revenue
moe_unsubscribe
You may create custom properties but you should not create properties with the following names "
id
"
, "
_id
"
, or ""
.
You can also identify a device to MoEngage , using the identify
API. With this API, you can create new properties or update the existing properties of the device.
A sample call for identifying device is as shown:
To track your users' actions, you can use the RudderStack track
API. You can call track
with eventname
and the associated properties.
For information on the track
call, please refer to our RudderStack API Specification guide.
A sample track
call is as shown:
The Alias api is used to merge two different profiles of a same user into a single profile.
Alias call can be done only through mobile sdks.
For more information, please refer to our RudderStack API Specification guide.
iOS Android
Run the following command to implement the alias
method in your iOS project:
Run the following command to implement the `alias` method in your Android project:
The reset method resets the previously identified user and the related information. For more information, please refer to our RudderStack API Specification guide.
iOS Android Run the following command to implement the reset
method in your iOS project:
Run the following command to implement the reset
method in your Android project:
RESET api is applicable only for Device Mode Connections
RudderStack maps the following properties to the MoEngage properties before sending them over MoEngage's HTTP API.
pushPreference
push_preference
active
active
userId
customer_id
name
name
firstname
/first_name
/firstName
first_name
lastname
/last_name
/lastName
last_name
email
email
age
age
gender
gender
mobile
mobile
source
source
createdAt
created_time
last_seen
/lastSeen
last_seen
transactions
transactions
revenue
revenue
moe_unsubscribe
/moeUnsubscribe
moe_unsubscribe
event
action
properties
attributes
iOS Android Web React Native
To send push notifications in iOS an APNS certificate needs to be created and has to be converted to .pem
file.
This .pem
file needs to be uploaded in the MoEngage dashboard.
In the target app turn on App Groups and enable one of the App group ids, in case if you don't have an App Group ID then create one. The name of your app group should be group.{bundle id}.MoEngage
.
Turn on Background mode and set/enable Remote Notification.
Turn on push notification capabilities in your app.
Before initializing add [MoEngage setAppGroupID:<your app group id>];
In case if you would like to keep the notifications even after the App Launch then : [MoEngage sharedInstance].disableBadgeReset = true;
For more detailed steps please follow MoEngage guidelines here.
In-app messaging is a type of mobile messaging where the notification is displayed within the app. Some examples include popups, yes/no prompts, interstitials, and more. To implement this please follow this guide: InApp NATIV. Copy the Server Key from the FCM console and add it to the MoEngage Dashboard(Not sure where to find the Server Key refer to Getting FCM Server Key. To upload it, go to the Settings Page and add the Server Key and package name. **Please make sure you add the keys both in the Test and Live environment.** Before configuring MoEngage SDK for receiving push notifications please make you have configured Firebase in your application, if not done already refer to the documentation and complete setup. Also, make sure you have added the Firebase Messaging dependency in your application build.gradle
file.
To show push notifications you need to add the notification small icon and large icon along with the AppId to the MoEngage.Builder
For showing Push notifications there are 2 important things
Registration for Push, i.e. generating push token.
Receiving the Push payload from Firebase Cloud Messaging(FCM) service and showing the notification on the device. The above can either be handled by the application or MoEngage SDK. There is some configuration required based on whether the above-mentioned things are handled by the application or SDK.
By default, MoEngage SDK attempts to register for push token, since your application is handling push you need to opt-out of SDK's token registration.
How to opt-out of MoEngage Registration?
To opt-out of MoEngage's token registration mechanism call in the optOutTokenRegistration()
on the MoEngage.Builder
as shown below
Pass the Push Token To MoEngage SDK
The Application would need to pass the Push Token received from FCM to the MoEngage SDK for the MoEngage platform to send out push notifications to the device. Use the below API to pass the push token to the MoEngage SDK.
_Note:_ Please make sure token is passed to MoEngage SDK whenever push token is refreshed and on application update. Passing token on application update is important for migration to the MoEngage Platform.
Passing the Push payload to the MoEngage SDK
To pass the push payload to the MoEngage SDK call the MoEngage API from the `onMessageReceived()` from the Firebase receiver. Before passing the payload to the MoEngage SDK you should check if the payload is from the MoEngage platform using the helper API provided by the SDK.
Push Registration and Receiving handled by SDK
Add the below code in your manifest file within the application tag
When MoEngage SDK handles push registration it optionally provides a callback to the Application whenever a new token is registered or token is refreshed. An application can get this callback by implementing FirebaseEventListener
and registering for a callback in the Application class' onCreate()
using MoEFireBaseHelper.getInstance().setEventListener()
In-app messaging is a type of mobile messaging where the notification is displayed within the app. Examples include popups, yes/no prompts, interstitials, and more. To implement this please follow: InApp NATIV
Go to Web Push Settings.
Under Web fill in the details as required.
For HTTPS Web Push to work, you need to host two files in the root
directory of your web server.
After clicking **SAVE**, please proceed to download serviceworker.js
file. Under Web Push Settings.
In case you already have your own serviceworker.js add :
HTTP : Select a sub-domain. For more details please follow the guidelines from MoEngage.
Open the android
folder of your React Native app and follow all the steps listed in the Android
tab of the Configuring Push Notifications section.
Open the ios
folder of your React Native app and follow all the steps listed in the iOS
tab of the Configuring Push Notifications section.
From the RudderStack dashboard, turn on the debug mode to get debug logs. The events will be seen under the Test section of the particular app in MoEngage.
MoEngage allows sending the time at which the event occurred and calculates the user local time by taking two parameters. current_time
and user_timezone_offset
where the current_time
is UTC Time at which the event happened, and user_timezone_offset
is the difference in seconds between the user local time and UTC.
The RudderStack transformer maps the current_time to timestamp or originalTimestamp value from the event payload sent to Rudder server. This value should be passed in UTC.
The user_timezone_offset is mapped to timezone field present under the context object of the event payload. This value should be passed as tz string. Rudder mobile SDKs populate the timezone field by itself. But for other sources like server like SDKs, HTTP api, the timezone needs to be set explicitly in every request.
Example payload:
MoEngage accepts user creation time for its user endpoint. This is reflected as first_Seen
in their dashboard.
The RudderStack transformer maps the created_time from the createdAt spec'd traits in our payload. The value should be in the ISO 8601 format. If the value is not in proper format or not present, MoEngage will put in the value by itself.
An example payload is as shown:
You can find your MoEngage API ID and API KEY in your moengage.com account under Settings > APIs > DATA API Settings.
If your app is in debug mode then you can see under Test otherwise you can see under Live. Go to For developers --> Recent Events.
If you come across any issues while configuring or using MoEngage with RudderStack, please feel free to contact us. You can also start a conversation in our Slack community; we will be happy to talk to you!