Cart Event
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.
Event Structure
All cart events require these fields:
| Field Name | Field Type | Description |
|---|---|---|
lineItem | Line Item Attribute | Required. A single line item attribute value. |
Event Types
The Cart Event supports these interaction types:
- Add To Cart: Track when customers add items to their shopping cart
- Remove From Cart: Track when customers remove items from their shopping cart
- Replace Cart: Track when customers replace their entire shopping cart contents
Add to Cart Event
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)Remove from Cart Event
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)Replace Cart Event
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)