Account Data
Account data is used to capture information about a customer’s business, organizational affiliation, or group rather than the individual user themselves. This is crucial when a single account (for example, a company, household, or organization) can have multiple users (individuals) associated with it. By attaching an accountId, you can group interactions and behaviors across all related users for holistic account-level analysis.
Account Data Structure
The account object includes these fields.
| Field | Type | Description |
|---|---|---|
account.id | string | Required. The unique identifier for the account. |
account.attributes | object | An object for any custom data you want to associate with the account, such as an industry, subscription tier, or company size. |
This JSON structure illustrates a typical account payload, including its unique identifier and custom attributes.
1{
2 "account": {
3 "id": "43296241300", // Unique identifier for the organization/account
4 "attributes": {
5 "role": "Subscriber" // Custom attribute: e.g., the account's subscription type
6 }
7 }
8}Examples of Sending Account Data
Send account data with an interaction to correctly attribute all interactions to the account.
This example demonstrates including account data alongside a specific user interaction with a product, ensuring 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 attributes: {
19 role: "Subscriber",
20 },
21 },
22});Capture Account Data Using the Sitemap
To automatically and consistently inject the account.id into all interaction events across your site, use the Sitemap. Inject this data using the 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