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.

Field Type Description
account.id string Required. The unique identifier for the account.

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

{
  "account": {
    "id": "43296241300" // Unique identifier for the organization/account
  }
}

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.

SalesforceInteractions.sendEvent({
  // The specific action the user performed
  interaction: {
    name: "View Catalog Object",
    catalogObject: {
      type: "Product",
      id: "product-xyz",
      attributes: {
        name: "Product XYZ",
        category: "Clothing",
        color: "Red",
      },
    },
  },
  // The organizational context for the user performing the action
  account: {
    id: "43296241300",
  },
});

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.

SalesforceInteractions.init().then(() => {
  const sitemapConfig = {
    global: {
      // The onActionEvent function runs immediately before any event is sent.
      onActionEvent: (event) => {
        const accountId = window.accountId; // Get the ID from your site's variable

        if (accountId) {
          // Inject the account ID into the event object
          event.account = event.account || {};
          event.account.id = accountId;
        }
        return event; // Always return the modified event
      },
    },
    pageTypes: [
      // Example of a page type definition that fires an interaction
      {
        name: "product_detail",
        isMatch: () => true, // Example simple matching rule
        interaction: {
          name: SalesforceInteractions.InteractionName.ViewCatalogObject,
          catalogObject: {
            type: "Product",
            id: "product-xyz",
            attributes: {
              name: "Product XYZ",
              category: "Clothing",
              color: "Red",
            },
          },
        },
      },
    ],
  };
  SalesforceInteractions.initSitemap(sitemapConfig);
});

See Also