# Cart abandoned

Learn how to check whether a user has abandoned a cart.

This expression checks whether the user abandoned a cart based on [Cart abandoned](/reference/event/types/ecommerce/cart-abandoned) events.

A cart is considered abandoned when a user adds items but does not complete the purchase before the session ends. When the session ends, that cart and its items are marked as abandoned.

> **Tracking required**
>
> Ensure your app tracks the [Cart modified](/reference/event/types/ecommerce/cart-modified) or [Cart viewed](/reference/event/types/ecommerce/cart-viewed) events. Otherwise, the expression will always evaluate to false.

## Syntax

The basic syntax for this expression is:

```cql
user has abandoned cart
```

You can optionally include the article for better readability:

```cql
user has abandoned a cart
```

The negation of the expression can be expressed as:

```cql
user has not abandoned a cart
```

You can refine the expression with filters, quantifiers, and time windows:

```cql
user has abandoned a cart /*<criteria>*/ /*<quantifier>*/ /*<window>*/
```

## Parameters

These are the supported parameters:

- `criteria`: [`Criteria`](/reference/cql/expressions/events/criteria/overview) (optional)

  Additional [filtering criteria](#event-properties) for the cart abandoned event.

- `quantifier`: [`Quantifier`](/reference/cql/expressions/events/quantifier) (optional)

  A quantifier to specify how many times the event must have occurred.

- `window`: [`TimeWindow`](/reference/cql/expressions/events/time-window) (optional)

  The time window during which the cart abandonment must have occurred.

## Event properties

The following event properties can be used within [criteria expressions](/reference/cql/expressions/events/criteria/overview):

- `currency`: `string`

  The currency in which the monetary values are expressed in the shopping cart, such as "USD" or "EUR".

- `subtotal`: `number|null`

  The total of all items and quantities in the shopping cart including applied item promotions.

- `shippingPrice`: `number|null`

  The total shipping price for the items in the shopping cart, including any handling charges.

- `taxes`: `object`

  The taxes associated with the transaction.

  It is expressed as a dictionary where the key is the tax name and the value is the tax amount.

  Example:

  ```json
  {
    "state": 3.1,
    "local": 1.5
  }
  ```

- `costs`: `object`

  The costs associated with the transaction, such as manufacturing costs, shipping costs not paid by the customer, or other costs.

  It is expressed as a dictionary where the key is the cost name and the value is the cost amount.

  Example:

  ```json
  {
    "manufacturing": 5.0,
    "packaging": 2.0
  }
  ```

- `discount`: `number|null`

  The amount of discount applied to the shopping cart, as an absolute value. For example, `10.00` for a $10 discount.

- `coupon`: `string|null`

  The coupon applied to the shopping cart. For example, "SUPER\_DEALS".

- `total`: `number`

  The total revenue or grand total associated with the transaction, including shipping, tax, and any other adjustment.

## Examples

You can check if a cart was abandoned:

```cql
user has abandoned a cart
```

Or verify that no cart was abandoned:

```cql
user has not abandoned a cart
```

You can also add conditions, such as checking if the cart's currency was USD:

```cql
user has abandoned a cart with currency "USD"
```

Or the number of carts abandoned:

```cql
user has abandoned a cart at least 2 times
```

You can even filter by time, such as checking if it was abandoned yesterday:

```cql
user has abandoned a cart yesterday
```

Combine filters, counts, and time windows in one expression:

```cql
user has abandoned a cart with currency "USD" at least 1 time last week
```

> **Scale plan**
>
> This feature is available only to accounts on the Scale plan. See the [pricing page](https://croct.com/pricing) for more information.

## Explore

- [Audiences](/explanation/audience): Understand how to delivery content to specific groups of users.
- [Event tracking](/reference/event/types/ecommerce/cart-abandoned): Learn more about this event.
