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.

AddToCartEvent(
    lineItem: LineItem(
        catalogObjectType: "Product",
        catalogObjectId: "product-1",
        quantity: 1,
        price: 20.0,
        currency: "USD",
        attributes: [
            "gift_wrap": false
        ]
    )
)
CartEvent.add(
    lineItem = LineItem(
        catalogObjectId = "product-1",
        catalogObjectType = "Product",
        quantity = 1,
        price = 20.0,
        currency = "USD",
        attributes = mapOf(
            "gift_wrap" to false
        )
    )
)

Remove from Cart Event

Track when customers remove items from their shopping cart.

RemoveFromCartEvent(
    lineItem: LineItem(
        catalogObjectType: "Product",
        catalogObjectId: "product-1",
        quantity: 1
    )
)
CartEvent.remove(
    lineItem = LineItem(
        catalogObjectId = "product-1",
        catalogObjectType = "Product",
        quantity = 1
    )
)

Replace Cart Event

Track when customers replace their entire shopping cart contents.

ReplaceCartEvent(
    lineItems: [
        LineItem(
            catalogObjectType: "Product",
            catalogObjectId: "product-1",
            quantity: 1
        ),
        LineItem(
            catalogObjectType: "Product",
            catalogObjectId: "product-2",
            quantity: 1,
            price: 20.0,
            currency: "USD",
            attributes: [
                "gift_wrap": false
            ]
        )
    ]
)
CartEvent.replace(
    lineItems = listOf(
        LineItem(
            catalogObjectType = "Product",
            catalogObjectId = "product-1",
            quantity = 1
        ),
        LineItem(
            catalogObjectType = "Product",
            catalogObjectId = "product-2",
            quantity = 1,
            price = 20.0,
            currency = "USD",
            attributes = mapOf(
                "gift_wrap" to false
            )
        )
    )
)