Identity Management
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()andsetAlias(). If you are using either of these methods, replace them 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.
If a network issue prevents the identifier from reaching the MoEngage server, the SDK caches the
identifyUser() call and retries automatically once the network is available or the next time the app opens.Logout
The application needs to notify the MoEngage SDK whenever the user is logged out of the application. Call the API whenever the user is logged out of the application to notify the SDK.identifyUser() again when the next user logs in. For how identifiers map to user profiles, refer to Identity resolution.
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 theonLogoutComplete event to detect successful logout.
Logout Callback Data
TheonLogoutComplete callback receives the following payload:
MoELogoutComplete for logout.accountMeta.appId - The Workspace ID of MoEngage.
platform - Native platform from which the callback is triggered. Possible values - android, ios
SDK User Attributes Keys
You can also set the default user attributes like mobile number, gender, user name, birthday, location, etc using the below APIsYou can not use “moe_” as a prefix while naming events, event attributes, or user attributes. It is a system prefix and using it might result in periodic blacklisting without prior communication.
Custom Boolean User Attribute
iOS(optional)
Starting from version 9.x.x of cordova-moengage-core, the default tracking for the custom boolean attribute will be changed to boolean(true/false) from double(0/1). To configure this, use analyticsConfig with shouldTrackUserAttributeBooleanAsNumber and pass true to track the boolean as double. By default, this is set as false to track boolean as true/false Refer to the initialization code snippet below.Reserved keywords for User Attributes
Below is the list of keys that should not be used 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