---
schema_version: "1"
id: a594d445f21e7cc60375851971e4db1b9ad0ae917f3cc5fde0fc18bbfd8fafa3
title: Track Items in Cart
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/mktg/264-0-0/mc_ctc_track_cart.md
canonical_url: https://help.salesforce.com/s/articleView?id=mktg.mc_ctc_track_cart.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 0d16d0aaf4484473f2882151cc948e3a19148697c94dff27add62b6b5b5721b1
description: Configure Collect Tracking Code to track items that are added or removed from a contact’s cart.
products:
  - Marketing
  - Marketing Cloud Intelligence
release: "264"
---
# Track Items in Cart

Configure Collect Tracking Code to track items that are added or removed from a contact’s cart.

Use `trackCart` anytime a shopping cart changes, such as when a visitor adds or removes a product to the cart, or updates the quantity of a product in the cart.

This code overwrites items in the contact’s cart with the newest information, including the quantity and unit price for each item. If a cart has multiple products, each product must be added to the call each time it’s captured. The active cart must be added to the call every time. This call is critical for Abandon Cart triggers, which uses this call to determine which products to show were abandoned.

The call is made up of name–value pairs. The only accepted names are `item`, `quantity`, `price`, and `unique_id`. Only `item` and `unique_id` are required.

Use the `trackCart` each time a product is added to the cart or the cart is updated. This activity often occurs on product pages, category pages, and shopping cart pages.

We recommend that you always include `setUserInfo` with `trackCart`. This practice helps to ensure that the correct Contact ID is always tied to the cart.

```
<script type="text/javascript">
    _etmc.push(["setOrgId", "MID"]);
    _etmc.push(["trackCart", {
        "cart": [
            {
                "item": "INSERT_ITEM",
                "quantity": "INSERT_QUANTITY",
                "price": "INSERT_PRICE",
                "unique_id": "INSERT_UNIQUE_ID"
            },
            {
                "item": "INSERT_ITEM",
                "quantity": "INSERT_QUANTITY",
                "price": "INSERT_PRICE",
                "unique_id": "INSERT_UNIQUE_ID"
            }
        ]
    }]);
</script>
```

1. Copy and customize the script.
2. Add the modified script in the header code on your detail pages.

#### See Also

- [Install Collect Tracking Code](https://help.salesforce.com/s/articleView?id=mktg.mc_ctc_install_collect_code.htm&release=264.0.0&type=5 "Learn how to configure your site to use Collect Tracking Code.")
- [Track Category Viewed](https://help.salesforce.com/s/articleView?id=mktg.mc_ctc_track_category_view.htm&release=264.0.0&type=5 "Configure Collect Tracking Code to store category data for the product a contact views on your website.")
- [Track In-Site Search](https://help.salesforce.com/s/articleView?id=mktg.mc_ctc_track_in_site_search.htm&release=264.0.0&type=5 "Configure Collect Tracking Code to store data about a contact’s search on your website.")
- [Track Page View](https://help.salesforce.com/s/articleView?id=mktg.mc_ctc_track_page_view.htm&release=264.0.0&type=5 "The trackPageView call is the most common call and can capture three types of information: product or content views, categories views, or search views.")
- [Track Purchase Details](https://help.salesforce.com/s/articleView?id=mktg.mc_ctc_track_conversion.htm&release=264.0.0&type=5 "Configure Collect Tracking Code to store details about a contact’s purchases from your website.")
- [Track User Rating](https://help.salesforce.com/s/articleView?id=mktg.mc_ctc_track_rating.htm&release=264.0.0&type=5 "Configure Collect Tracking Code to store contact ratings for items on your website.")

## Clear Cart

Use this code to clear all items from a contact’s cart when the contact manually removes all items from the cart.

This call is vital for implementations with Abandon Cart triggers, as contact receive unwanted abandon cart emails for products they cleared from their cart.

```
<script type="text/javascript">       
    _etmc.push(["setOrgId", "MID"]);
    _etmc.push(["trackCart", { "clear_cart": true } ]);
</script>
```

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-mktg-mc_data_management_and_analytics-264-0-0-production-enus/7988f60d-cd94-4b42-8836-dc11773564b5/images/icon_note.png)

Note The `trackConversion` method clears the contact cart automatically.