A line item is used to describe a single, specific instance of a purchasable item as it appears within a transaction, such as a shopping cart, an order, or a return.
Line items are only used within transactional interactions, specifically:
Line Item Object Structure
Line item objects are typically passed as an array (even if only one item is present) under the lineItems property of the main event payload.
| Field | Type | Description |
|---|---|---|
catalogObjectType |
string | Required. The type of catalog object being referenced (for example, Product, Service). |
catalogObjectId |
string | Required. The unique identifier for the specific item (such as, SKU). |
quantity |
number | Required. The number of units of this item in the transaction. |
price |
number | The unit price of the item. |
currency |
string | The currency code for the price field (for example, USD, EUR). |
attributes |
object | An object for any custom data specific to this line item. |
| Field | Type | Description |
|---|---|---|
attributes |
object | An object for any custom data specific to this line item. |
catalogObjectId |
string | Required. A unique identifier representing the catalog object referenced in the line item. |
catalogObjectType |
string | Required. A name representing the catalog object referenced in the line item. |
currency |
string | The currency of the price field. |
price |
number | The price of the catalog object referenced in the line item. |
quantity |
number | Required. The number of catalog objects in this line item. |
Example: Line Item in a Cart Interaction
This example shows how a line item is structured when used within a Cart View interaction, typically defined within a Sitemap to collect cart details on the cart page.
// This data would be collected and sent via SalesforceInteractions.sendEvent()
{
interaction: {
name: 'View Cart',
lineItems: [
// First Line Item
{
catalogObjectType: "Product",
catalogObjectId: "product-1",
quantity: 1,
price: 9.99,
currency: "USD",
attributes: {
giftWrapping: true // Custom attribute for this specific item
}
},
// Second Line Item
{
catalogObjectType: "Product",
catalogObjectId: "product-x",
quantity: 2,
price: 15.00,
currency: "USD"
}
]
}
}
See Also