User Data
User data represents an individual visitor’s profile. You use the user object to track profile information for a visitor, whether they are anonymous or known (logged-in).
The primary goal of sending user data is to enrich the visitor’s profile with descriptive information.
The user object is included within the event payload sent to the Salesforce Interactions SDK. It contains fields for profile attributes.
| Field | Type | Required | Description |
|---|---|---|---|
user.attributes | object | Yes | User-supplied values that contain descriptive data used to enrich the user’s profile (for example, firstName, lastName, city). |
user.attributes.eventType | string | Yes | Identifies the type of profile event. Must begin with a letter (a-zA-Z), can only contain alphanumeric characters and underscores, and can’t end with or have consecutive underscores. Maximum 80 characters. |
This structure shows the user object with user-supplied attributes:
You only need to send the user object when the visitor’s attributes are first discovered or updated (such as, after login, during registration, or upon form submission).
This example captures the user’s attributes immediately upon login or when their details are known, without an associated interaction.
You can send both an engagement event and a profile event in a single request. The interaction section is the source of the engagement event, and the user section is the source of the profile event.
Use the SDK’s global.onActionEvent handler to consistently inject user information across all events.
This example shows how to automatically attach a known email address (if available in a global variable like window.user_info) as a user attribute to every event.
The SDK automatically sends an anonymous identity event to Data Cloud when a new anonymous ID is detected. This event ensures a profile record exists for the visitor’s device so that engagement events can be linked to an identity, even before the visitor is known.
The automatic event is generated when both conditions are true:
- The anonymous ID changed. This occurs when the SDK generates a new anonymous ID on the visitor’s first page load, when
SalesforceInteractions.setAnonymousId(id)is called with a new value, or whenSalesforceInteractions.resetAnonymousId()generates a fresh ID. IfsetAnonymousIdis called with the same ID that’s already stored, no event is triggered. - The first action event after the ID change carries no profile data. If that action event already contains
user.attributeswith aneventType, the SDK skips the automatic event and uses the real profile data instead.
The automatic event is a minimal identity profile event with isAnonymous: true. It fires on the first onEventSend batch after the ID change, not at the moment the anonymous ID is set. If the visitor leaves the site before any action event fires, no identity event is sent. The anonymous profile record can be merged or overwritten when a real identity is established.
See Also