Account Data

Account data captures information about a customer’s business, organizational affiliation, or group rather than the individual user. Account data matters when a single account (for example, a company, household, or organization) has multiple users associated with it. By attaching an accountId, you group interactions and behaviors across all related users for holistic account-level analysis.

Account Data Structure 

The account object includes this field.

FieldTypeDescription
account.idstringRequired. The unique identifier for the account.

This JSON structure illustrates a typical account payload with its unique identifier.

1{
2  "account": {
3    "id": "43296241300" // Unique identifier for the organization/account
4  }
5}

Examples of Sending Account Data 

Send account data with an interaction to correctly attribute all interactions to the account.

This example includes account data alongside a specific user interaction with a product, so both the individual user’s behavior and their organizational context are captured.

1SalesforceInteractions.sendEvent({
2  // The specific action the user performed
3  interaction: {
4    name: "View Catalog Object",
5    catalogObject: {
6      type: "Product",
7      id: "product-xyz",
8      attributes: {
9        name: "Product XYZ",
10        category: "Clothing",
11        color: "Red",
12      },
13    },
14  },
15  // The organizational context for the user performing the action
16  account: {
17    id: "43296241300",
18  },
19});

Capture Account Data Using the Sitemap 

To inject the account.id into all interaction events across your site consistently, use the Sitemap’s onActionEvent global handler.

This example assumes the accountId is already available on the page, such as being stored in a global JavaScript variable like window.accountId.

1SalesforceInteractions.init().then(() => {
2  const sitemapConfig = {
3    global: {
4      // The onActionEvent function runs immediately before any event is sent.
5      onActionEvent: (event) => {
6        const accountId = window.accountId; // Get the ID from your site's variable
7
8        if (accountId) {
9          // Inject the account ID into the event object
10          event.account = event.account || {};
11          event.account.id = accountId;
12        }
13        return event; // Always return the modified event
14      },
15    },
16    pageTypes: [
17      // Example of a page type definition that fires an interaction
18      {
19        name: "product_detail",
20        isMatch: () => true, // Example simple matching rule
21        interaction: {
22          name: SalesforceInteractions.InteractionName.ViewCatalogObject,
23          catalogObject: {
24            type: "Product",
25            id: "product-xyz",
26            attributes: {
27              name: "Product XYZ",
28              category: "Clothing",
29              color: "Red",
30            },
31          },
32        },
33      },
34    ],
35  };
36  SalesforceInteractions.initSitemap(sitemapConfig);
37});

See Also