Skip to main content
Set up abandoned carts

Get started with abandoned carts, and test your implementation.

Gareth Burroughes avatar
Written by Gareth Burroughes
Updated over 3 months ago

Dotdigital for Adobe Commerce (Magento) or Shopify connector user?

If so, abandoned cart functionality is configured and implemented differently - and the information below does not apply. Instead, read the Dotdigital for Adobe Commerce or Shopify connector articles.

The Dotdigital Tag

The Dotdigital Tag simplifies the process of adding Dotdigital scripts to your site.


Before you start

If you answer no to any of these questions, we may not be able to add the abandoned carts feature:

  • Do you have a developer or agency who can make modifications to your website?

  • Can your ecommerce site generate a JSON object based on the example below?

  • Can this JSON object be presented on every page of the site after the cart is created?

  • On cart completion, are you able to send the complete cart, with a code to say it is completed?

There is also a further set of points to consider that may make installation harder:

  • Is it possible to access an abandoned cart from a single URL? For example, https://www.my-site.com/cart?id=12345.

  • Is it possible to test the payment process with a fake promo code or credit card number?

  • Is the your ecommerce site a single-page app, or are full page refreshes infrequent?

  • Is the domain of your ecommerce site the same as the domain for the checkout?

  • Is a different domain used for the mobile site and is this domain different to the checkout?

  • Are the checkout/payment options done through a third party? If so, what third party is used, and how is this implemented (for example, in an iframe)?

To provide us with the answers to the above, you must fill in our abandoned carts questionnaire.


Implementation schedule

The following details the typical steps for an integration implementation sequence. Each step is approximately a week, depending on specific requirements, testing, and so on.

Example JSON script

Here is an example of the script you will need to include in your site. This script will be customised for your site, and will need to be installed by yourselves or the people who developed your website.

A few pointers:

  • This should be on every page of your site, after the initial cart is created

  • Once the cart has been completed, this will need be done one last time with a cartPhase of ORDER_COMPLETE.

  • Once you know who your user is (when they register/log in), you will need to identify them with the identify request below.

  • The cartInsight script must be on the page before the cart tracking code is executed.

  • For single-page apps, you will need to manually call the tracking code when any user action occurs.

A full explanation of this script can be found in JSON breakdown.

Example script

// <![CDATA[
(function(w,d,u,t,o,c){w['dmtrackingobjectname']=o;c=d.createElement(t);c.async=1;c.src=u;t=d.getElementsByTagName 
                (t)[0];t.parentNode.insertBefore(c,t);w[o]=w[o]||function(){(w[o].q=w[o].q||[]).push(arguments);};
                })(window, document, '//static.trackedweb.net/js/_dmptv4.js', 'script', 'dmPt');window.dmPt('create', 'DM-SAMPLE-01');// Identify the user via email
window.dmPt('identify', 'example@example.com');// Track your cart
window.dmPt("cartInsight", {
   "programID": 12345,
   "cartDelay": 25,
   "cartID": "123ABC",
   "cartPhase": "CUSTOMER_LOGIN",
   "currency": "USD",
   "subtotal": 35.98,
   "discountAmount": 0,
   "taxAmount": 0,
   "grandTotal": 35.98,
   "cartUrl": "https://www.my-website.com/checkout/cart",
   "lineItems": [
      {
        "sku": "576879",
        "name": "Shirt",
        "description": "A super great description of the product",
        "category": "Shirts> T-Shirts  Blue",
        "other": {"fieldName": "This can be a string or any value you like"}
        "unitPrice": 11.99,
        "salePrice": 11.99,
        "quantity": 2,
        "totalPrice": 23.98,
        "imageUrl": "http://www.my-website.com/a/p/shirt.jpeg",
        "productUrl": "http://www.my-website.com/index.php/shirt.html",
      },
      {
        "sku": "1112296",
        "name": "Fleece Jacket",
        "description": "A well appointed Fleece jacket",
        "category": "Shirts  T-Shirts  Blue",
        "other": {"fieldName": "This can be a string or any value you like"}
        "unitPrice": 65.99,
        "salePrice": 55.50,
        "quantity": 1,
        "totalPrice": 55.50,
        "imageUrl": "http://www.my-website.com/a/p/fleece.jpeg",
        "productUrl": "http://www.my-website.com/index.php/fleece.html"
      }
   ]   
});
// ]]

Testing checklist

Once you have access to Dotdigital, and you have the tracking code:

  • Install the tracking code on your website

  • Check it is installed. In your browser’s console, type window.dmPt("version"). The version number should appear in the console window.

  • Create the JSON object, and make sure it is output after the Web Behaviour Tracking script. Tip: It is better to put the JSON object at the footer of your page, before the </body> tag, where possible.

  • Verify that, when there are no products in your cart, the JSON object is either not output, or there are simply no line items within the cart.

  • Add a product your cart, and verify that the JSON object is output, with the single product within

  • Add another product to your cart and verify the JSON object now has the two expected products within.

  • Verify that, as you navigate around your site, the JSON object is included on every page.

  • Remove a product from your cart, and verify the item has been removed.

  • Remove all items from your cart, and verify that the JSON object is present on your page, but has no line items within.

  • Add some products back to your cart, and go to your checkout page. Verify the JSON object is output on this page as expected.

  • Place a test order, and check that, once the order is complete, the JSON object is present, with a cartPhase of ORDER_COMPLETE.

Did this answer your question?