MoEngage highly recommends using the optional step for MoEngage Web SDK integration.
Pre-defined Attributes
Use the following MoEngage methods to make use of the standard user attributes.Custom Attributes
User Login and Logout
ID is used to uniquely identify a user within the MoEngage dashboard. Ensure log in and log out of users are implemented correctly during the visit to your website and users are authenticated. When you go live with MoEngage web SDK for the first time, ensure that you are setting the ID of your existing website users on page load. As soon as the user is authenticated, ensure that the user id is passed on to the MoEngage SDK using the login method. After the user logs out of your app, ensure to call the logout method of MoEngage. Use the following MoEngage methods on user login, user log out and user update:Log In
For SDK versions below 2.52.2 refer to this document.Please ensure that you are using the latest integration script before using the below MoEngage methods.
InformationUpdates are made to SDK functions to improve user identification and session management.
- Forced Logout: The MoEngage SDK no longer automatically logs out the previous user when a new user is detected on the device. Logout should now be explicitly called for workspaces enabled with Identity resolution to avoid data corruption.
- SetUniqueID: IdentifyUser function supports multiple identifiers, which replaces the need of using SetUniqueID function for user identification. Note that SetUniqueID is marked for removal in the future releases of SDK versions - it is important to use identifyUser instead especially if you are using Identity resolution in your workspace.
- SetAlias: For workspaces with the Identity resolution feature enabled, MoEngage SDK stores the previous identifier values. When IdentifyUser function is used to track the new identifier values, MoEngage SDK detects the change in identifier value and reports accordingly.
- If you call the IdentifyUser function without logging out, then the existing logged-in user’s ID is updated.
u_em, u_mb, uid are standard user attributes. Please refer to the below table to identify user with standard user attributes:
You can identify a user with custom user attributes as well if the same have been chosen as identities in your MoEngage dashboard.
Log Out
Logs out the current user.Update User
Track User Attributes
Ensure that you are tracking user attributes in the following cases:- When a new attribute is set for a user. For example, set the Email Id or Mobile No. attribute for the user after a user logs in or signs up on the website.
- When the value of an existing attribute is updated.
- When you go live for the first time with MoEngage web SDK integration, ensure that you are passing the user attributes set for your existing website users after page load (if they are not already sent to MoEngage).
- For more information on supported data types and data tracking policies, please refer to Data Tracking Policies.
Make sure that you are not using a single unique id for all the users, this is possible only when the unique id value is hardcoded, instead of retrieving from your servers.