The online Trailblazer Community becomes read-only Oct 30, 2026. Read More
Use a cart event to capture customer interactions when they modify the contents of their online shopping cart, including adding items, removing items, or replacing the entire cart.
All cart events require these fields:
| Field Name | Field Type | Description |
|---|---|---|
lineItem | Line Item Attribute | Required. A single line item attribute value. |
The Cart Event supports these interaction types:
Track when customers add items to their shopping cart.
1AddToCartEvent(
2 lineItem: LineItem(
3 catalogObjectType: "Product",
4 catalogObjectId: "product-1",
5 quantity: 1,
6 price: 20.0,
7 currency: "USD",
8 attributes: [
9 "gift_wrap": false
10 ]
11 )
12)1CartEvent.add(
2 lineItem = LineItem(
3 catalogObjectId = "product-1",
4 catalogObjectType = "Product",
5 quantity = 1,
6 price = 20.0,
7 currency = "USD",
8 attributes = mapOf(
9 "gift_wrap" to false
10 )
11 )
12)Track when customers remove items from their shopping cart.
1RemoveFromCartEvent(
2 lineItem: LineItem(
3 catalogObjectType: "Product",
4 catalogObjectId: "product-1",
5 quantity: 1
6 )
7)1CartEvent.remove(
2 lineItem = LineItem(
3 catalogObjectId = "product-1",
4 catalogObjectType = "Product",
5 quantity = 1
6 )
7)Track when customers replace their entire shopping cart contents.
1ReplaceCartEvent(
2 lineItems: [
3 LineItem(
4 catalogObjectType: "Product",
5 catalogObjectId: "product-1",
6 quantity: 1
7 ),
8 LineItem(
9 catalogObjectType: "Product",
10 catalogObjectId: "product-2",
11 quantity: 1,
12 price: 20.0,
13 currency: "USD",
14 attributes: [
15 "gift_wrap": false
16 ]
17 )
18 ]
19)1CartEvent.replace(
2 lineItems = listOf(
3 LineItem(
4 catalogObjectType = "Product",
5 catalogObjectId = "product-1",
6 quantity = 1
7 ),
8 LineItem(
9 catalogObjectType = "Product",
10 catalogObjectId = "product-2",
11 quantity = 1,
12 price = 20.0,
13 currency = "USD",
14 attributes = mapOf(
15 "gift_wrap" to false
16 )
17 )
18 )
19)