This article presents one of the methods of tracking cart contents in a web environment.  

While tracking the contents of a cart on a website, you may run into issues with session time or tracking events that add/remove items. To resolve this, you can retrieve and send custom events that include all the current contents of the cart.

An example usage of the cart status events is sending reminders to customers who leave their carts without completing a purchase and sending each update of the cart status to Synerise.


<div class="admonition admonition-warning"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z" /></svg></div><div class="admonition-body"><div class="admonition-content">

The events described here **do not** modify the cart. Their purpose is only to track the cart's current content for use in marketing scenarios, automations, and analytics.

</div></div></div>


## Authentication

Requests to the SDK may require customer authentication. For more details, see [this article](/developers/web/jwt-auth).

## Updating cart status
You must send `cart.status` immediately after the contents of the cart are modified. Example of a custom event that updates the status of a cart:


<pre><code class="language-javascript">SR.event.trackCustomEvent('cart.status', {
    products: [
        {
        sku: '236',
        quantity: 2,
        brand: 'brand1',
        category: 'cat1'
        },
        {
        sku: '436',
        quantity: 1,
        brand: 'brand1',
        category: 'cat1'
        }
    ],
    totalAmount: 150,
    totalQuantity: 3,
    itemIds: ["236","436"]
    }, 
'CartStatus');</code></pre>



<div class="admonition admonition-important"><div class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2.5"><path stroke-linecap="round" stroke-linejoin="round" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg></div><div class="admonition-body"><div class="admonition-content">

This custom event contains complete information about a cart - if you want to add an item, you must also include the items that were in the cart before.

</div></div></div>


### Parameters

| Name | Type | Mandatory | Description |
| --- | --- | --- | --- |
| `products` | array | yes | An array of items in the cart. Cannot contain duplicates. |
| `sku` | string | yes | The SKU of the item. Must be the same as the `product:retailer_part_no` value in OG tags and `<g:id>` or `g:item_group_id` in the product feed. |
| `quantity` | float | yes | The quantity of the item in the cart |
| `brand` | string | no | The brand of the item |
| `category` | string/array | no | A category (string) or categories (array of strings) that the item belongs to. Must be the same as the `og:category` in OG tags and `<g:product_type>` in the product feed. |
| `totalAmount` | float | no | The total value of the cart |
| `totalQuantity` | float | no | The total quantity of items in the cart |
| `itemIds`| array | recommended | This is a parameter that stores item IDs from the cart. Thanks to this parameter, you don't need to extract `sku` values from the `products` array to to create analytics based on item IDs; create recommendations; or exclude items from a recommendation if they're already in the cart. |

## Clearing a cart

When all the contents of a cart are removed, send a status event with an empty cart.

This must be done when a transaction is completed.


<pre><code class="language-javascript">SR.event.trackCustomEvent('cart.status', {
products: [],
totalAmount: 0,
totalQuantity: 0
}, 'CartStatus');</code></pre>
