- 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 usingsetUniqueId(), replace it withidentifyUser(). - 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.
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.
Logout
Call this API when the user logs out of your application.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 thelogoutCompleted 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.setUserAttribute() method:
Custom boolean user attribute
iOS only: Starting from version 5.x.x ofcapacitor-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_IDUSER_ATTRIBUTE_USER_EMAILUSER_ATTRIBUTE_USER_MOBILEUSER_ATTRIBUTE_USER_NAMEUSER_ATTRIBUTE_USER_GENDERUSER_ATTRIBUTE_USER_FIRST_NAMEUSER_ATTRIBUTE_USER_LAST_NAMEUSER_ATTRIBUTE_USER_BDAYUSER_ATTRIBUTE_NOTIFICATION_PREFUSER_ATTRIBUTE_OLD_IDMOE_TIME_FORMATMOE_TIME_TIMEZONEUSER_ATTRIBUTE_DND_START_TIMEUSER_ATTRIBUTE_DND_END_TIMEMOE_GAIDINSTALLUPDATEMOE_ISLATstatususer_idsource