Order Interaction
An Order interaction is an ecommerce event used to capture actions related to new, in progress, or completed orders. This is the standard interaction data model for reporting purchases, returns, cancellations, and other order lifecycle events.
Order Interaction Structure
The order object defines the details of the transaction, while interaction.name defines the action being taken.
| Field Name | Field Type | Description |
|---|---|---|
name | string | Required. The type of order interaction that occurred. Use the standard SDK constants for this field. For example, Purchase, Return, and so on. |
order.id | string | Required. A unique identifier representing the order. |
order.totalValue | number | Required. The total value of the order. |
order.lineItems | Line Item Data | An array of Line Item Data values. |
order.currency | string | The currency of the order. |
order.attributes | object | A user-supplied value. |
Here’s the structure of an order interaction with the minimum required fields, lineItems, and optional attributes.
1{
2 "interaction": {
3 "name": "Purchase",
4 "order": {
5 "id": "9432", // Required: Unique Order ID
6 "totalValue": 9.99, // Required: Final price
7 "currency": "USD",
8 "lineItems": [
9 {
10 // Array of purchased items
11 "catalogObjectType": "Product",
12 "catalogObjectId": "product-xyz",
13 "quantity": 1,
14 "price": 9.99,
15 "attributes": {
16 "giftWrapping": 1
17 }
18 }
19 ]
20 },
21 "attributes": {
22 // Attributes for the entire interaction/order
23 "promoCode": "SAVE10"
24 }
25 }
26}Standard Interaction Names
Always use the built-in constants for the interaction.name field to ensure consistency across your instrumentation.
| Name | Value |
|---|---|
SalesforceInteractions.OrderInteractionName.Purchase | Purchase |
SalesforceInteractions.OrderInteractionName.Return | Return |
SalesforceInteractions.OrderInteractionName.Cancel | Cancel |
SalesforceInteractions.OrderInteractionName.Preorder | Preorder |
SalesforceInteractions.OrderInteractionName.Exchange | Exchange |
SalesforceInteractions.OrderInteractionName.Ship | Ship |
SalesforceInteractions.OrderInteractionName.Deliver | Deliver |
Implementation Examples
Using the SDK
This example shows how to capture a purchase interaction, typically fired once on the order confirmation page.
1SalesforceInteractions.sendEvent({
2 interaction: {
3 name: "Purchase",
4 order: {
5 id: "9432",
6 totalValue: 9.99,
7 currency: "USD",
8 lineItems: [
9 {
10 catalogObjectType: "Product",
11 catalogObjectId: "product-xyz",
12 quantity: 1,
13 price: 9.99,
14 attributes: {
15 giftWrapping: 1,
16 },
17 },
18 ],
19 },
20 attributes: {
21 promoCode: "SAVE10",
22 },
23 },
24});Using the Sitemap
Here’s how to use the sitemap to automatically fire a purchase event.
1SalesforceInteractions.init().then(() => {
2 const sitemapConfig = {
3 global: {},
4 pageTypes: [
5 {
6 name: "product_detail",
7 isMatch: () => true,
8 interaction: {
9 name: SalesforceInteractions.OrderInteractionName.Purchase,
10 order: {
11 id: "9432",
12 totalValue: 9.99,
13 currency: "USD",
14 lineItems: [
15 {
16 catalogObjectType: "Product",
17 catalogObjectId: "product-xyz",
18 quantity: 1,
19 price: 9.99,
20 attributes: {
21 giftWrapping: 1,
22 },
23 },
24 ],
25 },
26 attributes: {
27 promoCode: "SAVE10",
28 },
29 },
30 },
31 ],
32 };
33 SalesforceInteractions.initSitemap(sitemapConfig);
34});See Also