Loading
Einstein and Analytics in Marketing Cloud Engagement
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Track Items in Cart

          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.

          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
          Note The trackConversion method clears the contact cart automatically.
           
          Loading
          Salesforce Help | Article