WebEngage allows you to attach attributes to logged-in as well as anonymous users.
Attributes are a set of properties that make up a user profile. This profile information can be used to segment users which allows for better targeting based on different user personas.
All User related API's are part of WebEngage Android SDK's
You get an instance of WebEngage
User object as follows:
// import WebEngage 'User' import com.webengage.sdk.android.User; // Get an instance of `User` object User weUser = WebEngage.get().user();
Use following API to identify a user to WebEngage:
When a user Logs-In (
IMP: Please make sure to call above api as soon as a user logs into your application, or whenever earliest you are able to identify him/her.
Once called, every session, user attribute and event will be attributed to this user.
All attributes, events and session information accumulated before this API has been called gets associated to an anonymous user created by default. Once this anonymous user is identified (by using
loggedIn()API call), all of this stored information is attributed to this
When a user Logs-Out (
When a user logs out of your application then
Call this when the
logged-inuser logs-out, or, you do not want to attach any future event, session and/or user data with this user, unless
loggedInis called again.
Use these API's to attach custom attributes to the user
weUser.setAttribute(String attributeName,String value) weUser.setAttribute(String attributeName,Boolean value) weUser.setAttribute(String attributeName,Long value) weUser.setAttribute(String attributeName,Double value) weUser.setAttribute(String attributeName,Integer value) weUser.setAttribute(String attributeName,Date value) weUser.setAttribute(String attributeName,List<? extends Object> values)
IMP: Following java data types are allowed for above API's:
Listitself can contain one of these data types.
IMPORTANT: None of the attributeNames should start with
we_, else they'll be ignored. Attribute names starting with
we_are reserved for WebEngage's internal uses.
weUser.setAttributes(Map<String,? extends Object> attributes)
The values in above
Mapshould only be one of the above defined data types, or a
List. If the value is of
Listtype, it should not contain any other data type other than defined above.
weUser.setEmail(String email) weUser.setHashedEmail(String hashedEmail) weUser.setBirthDate(Integer year,Integer month,Integer day) // Month is index 1 based: January = 1, weUser.setPhoneNumber(String phoneNumber) weUser.setHashedPhoneNumber(String hashedPhoneNumber) weUser.setGender(Gender gender) weUser.setFirstName(String firstName) weUser.setLastName(String lastName) weUser.setCompany(String company) weUser.setUserProfile(UserProfile userProfile) // Use this to set user profile in one go using `Java Builder Pattern`
The upper bound on attribute name and its value(in case of String) is 50 and 1000 chars respectively.Anything beyond that will be truncated.
weUser.deleteAttribute(String attributeKey) weUser.deleteAttributes(List<String> attributeKeys)