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.

{
  "interaction": {
    "name": "Purchase",
    "order": {
      "id": "9432", // Required: Unique Order ID
      "totalValue": 9.99, // Required: Final price
      "currency": "USD",
      "lineItems": [
        {
          // Array of purchased items
          "catalogObjectType": "Product",
          "catalogObjectId": "product-xyz",
          "quantity": 1,
          "price": 9.99,
          "attributes": {
            "giftWrapping": 1
          }
        }
      ]
    },
    "attributes": {
      // Attributes for the entire interaction/order
      "promoCode": "SAVE10"
    }
  }
}

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.

SalesforceInteractions.sendEvent({
  interaction: {
    name: "Purchase",
    order: {
      id: "9432",
      totalValue: 9.99,
      currency: "USD",
      lineItems: [
        {
          catalogObjectType: "Product",
          catalogObjectId: "product-xyz",
          quantity: 1,
          price: 9.99,
          attributes: {
            giftWrapping: 1,
          },
        },
      ],
    },
    attributes: {
      promoCode: "SAVE10",
    },
  },
});

Using the Sitemap

Here's how to use the sitemap to automatically fire a purchase event.

SalesforceInteractions.init().then(() => {
  const sitemapConfig = {
    global: {},
    pageTypes: [
      {
        name: "product_detail",
        isMatch: () => true,
        interaction: {
          name: SalesforceInteractions.OrderInteractionName.Purchase,
          order: {
            id: "9432",
            totalValue: 9.99,
            currency: "USD",
            lineItems: [
              {
                catalogObjectType: "Product",
                catalogObjectId: "product-xyz",
                quantity: 1,
                price: 9.99,
                attributes: {
                  giftWrapping: 1,
                },
              },
            ],
          },
          attributes: {
            promoCode: "SAVE10",
          },
        },
      },
    ],
  };
  SalesforceInteractions.initSitemap(sitemapConfig);
});

See Also