User Data

Track profile data for a user with or without an associated interaction using Salesforce Interactions Web SDK.
1{
2   user: {
3        anonymousId: '<Set by SDK>',
4        identities: {
5            loyaltyId: "885627312393"
6        },
7        attributes: {
8            firstName: 'Joe',
9            lastName: 'Smith',
10            email: 'joe.smith@domain.com'
11        }
12   }
13}
User object fields:
Field Name Field Type Description
anonymousId string This field is managed by the SDK and is automatically attached to every event.
user.attributes object A user-supplied value.
user.identities object A user-supplied value to link the anonymous user with a known user.

Example

Here’s how a user profile data is captured using the Web SDK without Interaction.

1SalesforceInteractions.sendEvent({
2    user: {
3        identities: {
4            loyaltyId: "885627312393"
5        },
6        attributes: {
7            firstName: 'Joe',
8            lastName: 'Smith',
9            email: 'joe.smith@domain.com'
10        }
11    }
12})

Here’s how a user profile data is captured using the Web SDK with Interaction.

1SalesforceInteractions.sendEvent({
2   interaction: {
3        name: 'View Catalog Object',
4        catalogObject: {
5            type: 'Product',
6            id: 'product-xyz',
7            attributes: {
8                name: 'Product XYZ',
9                category: 'Clothing',
10                color: 'Red'
11            }
12        }
13    },
14    user: {
15        identities: {
16            loyaltyId: "885627312393"
17        },
18        attributes: {
19            firstName: 'Joe',
20            lastName: 'Smith',
21            email: 'joe.smith@domain.com'
22        }
23    }
24})

Here’s how a user profile data is captured using a Sitemap.

1SalesforceInteractions.init().then(() => {
2   const sitemapConfig = {
3        global: {
4            onActionEvent: (event) => {
5                const email = window.user_info && window.user_info.email;
6                if (email) {
7                    event.user = event.user || {};
8                    event.user.attributes = event.user.attributes || {};
9                    event.user.attributes.emailAddress = email;
10                }
11                return event;
12            },
13        },
14        pageTypes: [{
15            name: 'product_detail',
16            isMatch: () => true,
17            interaction: {
18            name: SalesforceInteractions.InteractionName.ViewCatalogObject,
19                catalogObject: {
20                    type: 'Product',
21                    id: 'product-xyz',
22                    attributes: {
23                        name: 'Product XYZ',
24                        category: 'Clothing',
25                        color: 'Red'
26                    }
27                }
28            }
29        }]
30    }
31    SalesforceInteractions.initSitemap(sitemapConfig)
32})