User Attributes are pieces of information you know about a user. They could be demographics like age or gender, account-specific like plan, or whether a user has seen a particular A/B test variation. User attributes are a customer identity you can reference throughout the customer’s lifetime.Documentation Index
Fetch the complete documentation index at: https://moengage-crashes-in-debug-feedback.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Identifying Users
For SDK versions below 9.23.0 refer to this document. Setting identifiers is important to:- To tie user behavior across platforms, i.e., iOS, Android, Web, etc.
- This is to ensure unnecessary or stale users are not created.
- To identify users across installs/re-installs.
Single Identifier
Call the API below to pass the identifier on to the MoEngage SDK.This method is a replacement for the deprecated setUniqueId(). If you are using ***setUniqueId() ***in your application, consider replacing it with identifyUser()**.
Multiple Identifiers
If your application has multiple identifiers using which you identify a user you can pass all the identifiers to the SDK using the below API.identifyUser() multiple times with different identifier names, the SDK will append this identifier to the already set identifiers.
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.
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.Default User Attributes
Some default SDK User Attribute can be set for eg. email-id, mobile number, gender, user name, birthday. The default attributes tracked by SDK can be set as shown below:- User Phone No / Mobile Number must be tracked as a string to work properly in MoEngage systems.
- For more information on supported data types and data tracking policies, refer to Data Tracking Policies.
DEBUG versus release builds, refer to Validations and restrictions.
Custom User Attributes
To set custom attributes just provide custom keys different to the ones present in here. Following is an example:JSON Attributes
From MoEngage-iOS-SDK v9.17.5, we have added support for JSON and array of JSON user attributes. Following is an example:Date and Time User Attributes
Date and time attributes can be set as user attributes. For this refer to the methods in the code block below:Location Attributes
The location of a user or any location can be set as user attribute. For this use setLocation(_:withAttributeName:) method and pass lat, the long value of the location as shown in the following example:Validations and restrictions
User attributes have two layers of validation that apply across bothDEBUG and release builds:
- Naming and format rules — these always apply, regardless of build configuration.
- Type validation — invalid attribute values cause a fatal exception in
DEBUGbuilds and are silently dropped in release builds.
In the iOS SDK,
DEBUG mode means the SDK was initialized using initializeDefaultTestInstance(_:) (TEST workspace) and the app is running attached to Xcode. This is different from a release build that has debug symbols enabled.Naming and format rules
- Attribute names must be non-empty. Passing an empty string (
"") as an attribute name causes a fatal exception inDEBUGbuilds. In release builds, the attribute is dropped. - No dot (
.) in attribute names. - Attribute names must not start with a dollar sign (
$). - Reserved prefix. You cannot use
moe_as a prefix when naming events, event attributes, or user attributes. It is a system prefix, and using it might result in periodic blocklisting without prior communication. - Reserved keywords. Do not use any of the following keys when tracking user attributes — they are reserved for SDK and system use:
USER_ATTRIBUTE_UNIQUE_IDUSER_ATTRIBUTE_USER_EMAILUSER_ATTRIBUTE_USER_MOBILEUSER_ATTRIBUTE_USER_NAMEUSER_ATTRIBUTE_USER_GENDERUSER_ATTRIBUTE_USER_FIRST_NAMEUSER_ATTRIBUTE_USER_LAST_NAMEUSER_ATTRIBUTE_USER_BDAYUSER_ATTRIBUTE_NOTIFICATION_PREFUSER_ATTRIBUTE_OLD_IDUSER_ATTRIBUTE_DND_START_TIMEUSER_ATTRIBUTE_DND_END_TIMEMOE_TIME_FORMATMOE_TIME_TIMEZONEMOE_GAIDMOE_ISLATINSTALLUPDATEstatususer_id
Supported attribute value types
Attribute values must be one of:String, Number, Date, MoEngageGeoLocation, Dictionary, or Array (of strings or numbers). NSURL is not supported — convert to a string before passing it.
If an unsupported value is passed:
- In
DEBUGbuilds, the SDK throws a fatal exception and crashes the app so you can catch data issues early. - In release builds, the SDK drops the specific invalid attribute. Other attributes set on the user are unaffected.
DEBUG exception:
- Passing
null(NSNull()). - Passing custom models or UI elements (for example,
UIColor,UIImage). - Passing invalid numbers like
NaNorInfinity. - Passing empty Arrays or Dictionaries.
- Nesting
DateorMoEngageGeoLocationobjects inside an Array or Dictionary. These must be passed directly as values.