Tracking User Attributes

User attributes are specific traits of a user such as an email, username, mobile, gender and so on. User Attributes helps target users based on these attributes across devices or installs or to personalize the messages.

User Login and Logout

It is important that you handle user login and logout as mentioned below. There is a definite possibility that your data gets corrupted if this is not done properly.

Ensure that you have the unique id for your app users and pass that information to MoEngage SDK using the setUniqueId(). The unique id is used to identify a user across installs and platforms and provide a unified view. After the user logs out of your app, it is necessary to call logout() so that we create a new user.

Ensure that you call the following methods on user log in or log out.


var moe = MoECordova.init(YOUR_APP_ID);


The application needs to notify the MoEngage SDK whenever the user is logged out of the application. To notify the SDK, call the API whenever the user is logged out of the application.


var moe = MoECordova.init(YOUR_APP_ID);


To clear out the existing user's data and his identity, call the logout method. This will clear the data for the current user and create a new one, when you re-login as explained in the above log-in scenario your user will be merged (if already exist in our system)

Updating User Attribute Unique ID

In a scenario where you have to update the User Attribute Unique ID value for a logged-in user use setAlias: method as shown below:

var moe = MoECordova.init(YOUR_APP_ID);


Please make sure that you use setAlias: for updating the User Attribute Unique ID and not setUserAttribute: with USER_ATTRIBUTE_UNIQUE_ID attribute and a new value, as this will reset the current user and lead to the creation of unintended users in our system.

SDK User Attributes Keys

You can also set the default user attributes like mobile number, gender, user name, birthday, location, etc using the below APIs

    var moe = MoECordova.init(YOUR_APP_ID);
    moe.setGender("Male"); // OR Female
    moe.setLocation(25.23, 73.23);
    // Format - ISO-8601 String

Date attributes and Birthday in ISO-8601 format - yyyy-MM-dd'T'HH:mm:ss'Z'

var moe = MoECordova.init(YOUR_APP_ID);
moe.setUserAttributeLocation("attribute", 25.23, 73.23);

You can use following method set the timestamp user attribute :

var moe = MoECordova.init(YOUR_APP_ID);
moe.setUserAttributeISODateString("LastPurchaseDate", "1970-01-01T12:00:00Z");
Was this article helpful?
0 out of 0 found this helpful