This information is helpful in order to targeting users based on these attributes across devices or installs.
The below example outlines the how to track a user attribute in MoEngage.
Please use the following helper functions to make use of the MoEngage reserved attributes which are available by default in the segmentation options.
Moengage.add_first_name("Dominick"); Moengage.add_last_name("Cobb"); Moengage.add_email("[email protected]"); Moengage.add_mobile("+12399999999"); Moengage.add_user_name("Dominick (Dom) Cobb"); // Full name for user Moengage.add_gender("M"); Moengage.add_birthday(new Date(1980, 2, 31));
Tracking Date/Time Attributes
It is important that you handle user login and logout as mentioned below. There is a definite chance that your data can get corrupted if not done properly.
Whenever your app can get hold of the unique id set for the user, pass that information to our SDK using the login method. We use the unique id information that you pass to our SDK, to identify a user. Once the user logs out of your app, It is necessary to call logout method of MoEngage, so that we track it as a new user. If you pass 2 different unique id information without calling logout method in between, older user information will be overwritten by the new user which is undesired.
When you go live with MoEngage web SDK for the first time, please ensure that you are setting the unique id of your existing website users on page load.
Kindly make sure that you call the following methods on user login/logout.
Moengage.add_unique_user_id(UNIQUE_ID); // UNIQUE_ID is used to uniquely identify a user.
Moengage.add_unique_user_id(NEW_UNIQUE_ID);with a new unique id will forcefully logs out the current user and create a new user. If you want to do this, then
Moengage.update_unique_user_id(NEW_UNIQUE_ID);is the correct way
This function will create new user with the NEW_UNIQUE_ID and forcefully logs out the current user.
Please make sure that you use
update_unique_user_id()for updating the User Attribute Unique ID and not
add_unique_user_id: as calling
add_unique_user_idwith a new value will reset the current user and lead to creation of unintended users in our system.
Please 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 / 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, please ensure that you are passing the user attributes set for your existing website users once on page load (if they are not already sent to MoEngage).
UNIQUE ID chaos
Kindly make sure that you are not using a single unique id for all the users, this can happen if you hard code the value, instead of fetching it from your servers.
Before you take your Website LIVE
In case you are taking your website live, do ensure -
- To pass debug_logs: 0 parameter in Moengage initialization in HTML code as mentioned below to send website data to LIVE environment on Dashboard (top toggle switch on Dashboard to right).
app_id: "YOUR_APP_ID_GOES_HERE", debug_logs: 0
- To configure the Web Push Settings in the LIVE environment by navigating to Settings -> Channel -> Push -> Web Push. Read more about TEST/LIVE environment here
You can also place the above function as a Custom HTML Tag inside GTM. This Tag can be fired once per event/page and triggered on the elements where you wish to track website user attributes. These attributes can be picked up from GTM Data Layer.
These are the default data collected by SDK. Please go through this before adding any events:
Updated about a month ago