---
schema_version: "1"
id: 8774cf1ac7d138cefcd7c9e13413f3104cb6cbb30cb6b6af28d818139989123f
title: Cart Event
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-engagement-mobile-sdk/guides/c360a-api-engagement-mobile-sdk-cart-event.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-engagement-mobile-sdk/guide/c360a-api-engagement-mobile-sdk-cart-event.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 07807384eaba98a196f34bce1bd58645e216b957f2b15ff2cf0a359d76627a12
products:
  - Data 360 Engagement Mobile SDK
  - Data 360 Developer Documentation
---
# 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](https://developer.salesforce.com/docs/data/data-cloud-engagement-mobile-sdk/guide/c360a-api-engagement-mobile-sdk-line-item-attribute.md) | 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
            )
        )
    )
)
```
