Skip to main content
MoEngage distinguishes between two types of user data:
  • Identifiers — values that uniquely identify a user across devices and platforms. Use identifyUser() to set these.
  • User attributes — properties you know about a user such as name, email, or plan type. Use setUserAttribute() to set these.

Identity management

For SDK versions below 6.0.0, refer to this document. Setting identifiers is important to:
  • Tie user behavior across platforms.
  • Ensure unnecessary or stale users are not created.
  • Identify users across installs and re-installs.

Login with a single identifier

Call the API below to pass the identifier to the MoEngage SDK.
  • This method replaces the deprecated setUniqueId(). If you are using setUniqueId(), replace it with identifyUser().
  • The following values are not allowed in the identifier field: unknown, guest, null, 0, 1, true, false, user_attribute_unique_id, (empty), na, n/a, "", dummy_seller_code, user_id, id, customer_id, uid, userid, none, -2, -1, 2.

Login with multiple identifiers

If your application has multiple identifiers for a user, pass all identifiers to the SDK using the API below.
Use the standard identifier keys below when passing common attributes as identifiers: For custom identifiers, use any key name that is not in the reserved keywords list. Behavior of multiple identifyUser() calls:
  • If you call identifyUser() without logging out first, the existing logged-in user’s identifiers are updated.
  • If you call identifyUser() multiple times with different identifier names, the SDK appends the new identifier to the already set identifiers. Refer to the Identity resolution documentation to learn more.
  • For workspaces with Identity resolution enabled, the SDK stores previous identifier values and detects changes when identifyUser() is called with new values.
Behavior change in SDK 6.0.0: The SDK no longer automatically logs out the previous user when a new user is detected. Call logoutUser() explicitly before identifying a new user to avoid data corruption.

Logout

Call this API when the user logs out of your application.
If your application registers for push tokens, pass the new push token to the MoEngage SDK after the user logs out. For more information, refer to

Logout callback listener

Clearing user data and resetting the SDK state is an asynchronous process. Wait for the SDK to complete logout before navigating the user away or clearing your app’s local state. Register a listener for the logoutCompleted event to detect successful logout. Wait for the callback to track any events/user attributes for the new user after the method is called.

Logout callback data

Setting user attributes

You cannot use moe_ as a prefix when naming events, event attributes, or user attributes. It is a system prefix and using it may result in periodic blacklisting without prior communication.
Use the following methods to set standard user attributes such as name, email, and mobile number.
For custom attributes, use the generic setUserAttribute() method:

Custom boolean user attribute

iOS only: Starting from version 5.x.x of capacitor-moengage-core, the default tracking format for custom boolean attributes changed from double to boolean. Use MoEAnalyticsConfig to configure this behavior.

Reserved keywords

Do not use the following keys when tracking user attributes:
  • USER_ATTRIBUTE_UNIQUE_ID
  • USER_ATTRIBUTE_USER_EMAIL
  • USER_ATTRIBUTE_USER_MOBILE
  • USER_ATTRIBUTE_USER_NAME
  • USER_ATTRIBUTE_USER_GENDER
  • USER_ATTRIBUTE_USER_FIRST_NAME
  • USER_ATTRIBUTE_USER_LAST_NAME
  • USER_ATTRIBUTE_USER_BDAY
  • USER_ATTRIBUTE_NOTIFICATION_PREF
  • USER_ATTRIBUTE_OLD_ID
  • MOE_TIME_FORMAT
  • MOE_TIME_TIMEZONE
  • USER_ATTRIBUTE_DND_START_TIME
  • USER_ATTRIBUTE_DND_END_TIME
  • MOE_GAID
  • INSTALL
  • UPDATE
  • MOE_ISLAT
  • status
  • user_id
  • source