Cart Event

Use a cart event interaction to capture when a customer modifies the contents of their online shopping cart.
Field Name Field Type Description
lineItem Line Item Attribute Required. A single line item attribute value.

Add To Cart Example

iOS
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)
Android
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 Example

Field Name Field Type Description
lineItem Line Item Attribute Required. A single Line Item Attribute value.
iOS
1RemoveFromCartEvent(
2    lineItem: LineItem(
3        catalogObjectType: "Product",
4        catalogObjectId: "product-1",
5        quantity: 1
6    )
7)
Android
1CartEvent.remove(
2    lineItem = LineItem(
3        catalogObjectId = "product-1",
4        catalogObjectType = "Product",
5        quantity = 1
6    )
7)

Replace Cart Example

Field Name Field Type Description
lineItem Line Item Attribute Required. A single Line Item Attribute value.
iOS
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)
Android
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)