All Collections
Abandoned carts
Abandoned cart JSON breakdown
Abandoned cart JSON breakdown
Gareth Burroughes avatar
Written by Gareth Burroughes
Updated over a week 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. Please instead read the Dotdigital for Adobe Commerce or Shopify connector articles.

Tracking script

This code needs to be included on every page and must be included before any calls are made to window.dmPt.

Your site identification number - shown below as DM-SAMPLE-01 - will be given to you prior to setup. The rest of this script block should remain exactly as it is below.

                })(window, document, '//', 'script','dmPt');window.dmPt('create', 'DM-SAMPLE-01'); window.dmPt('track');

Advanced use: If dmPt clashes with another variable on your page, you can change this above (before the identification code). Changing this will mean all calls to window.dmPt below will also need to be changed to window.myNewVar throughout.

Identifying your user

When you're able to identify your user (for example, after they've signed in), you must tell us who the user is. Without this, we may not be able to send them an abandoned cart email.

window.dmPt('identify', '');


The above script doesn't create a contact in your account. You need to already have a process in place in which customers are created as contacts when they log in, or sign up to, your site.

Supplying your cart

The code below needs to be executed on every single page after the cart has been created. Failure to do so may result in them getting an abandoned cart email too early.

A breakdown of what every field means can be found below.

window.dmPt("cartInsight", {
   "programID": 12345,
   "cartDelay": 25,
   "cartID": "123ABC",
   "cartPhase": "CUSTOMER_LOGIN",
   "currency": "USD",
   "subtotal": 35.98,   "shipping": 0,
   "discountAmount": 0,
   "taxAmount": 0,
   "grandTotal": 35.98,
   "cartUrl": "",
   "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": "",
        "productUrl": ""
        "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": "",
        "productUrl": ""

Cart JSON field breakdown

Cart detail fields

  • programID
    This is the ID of the Dotdigital program that will send out the email. We can supply this to you when we set up the email and program for you.

  • cartDelay
    This is the time, in minutes, we wait before sending out the email

  • cartID
    The ID of your shopping cart. This should be unique.

  • cartPhase
    The state in which the cart is in. It must be set to ORDER_COMPLETE once the order has been completed. This will prevent an abandoned cart email being sent.

  • currency
    The currency that the prices are in (e.g. USD or GBP)

  • subtotal
    The cart subtotal amount

  • shipping
    The amount for shipping the order

  • discountAmount
    The amount discounted on the entire order

    This should be a positive value.

  • taxAmount
    The amount of tax included on the entire order

  • grandTotal
    The final total of the order, including tax, discounts, etc., if known

  • cartUrl
    The cart URL that will take the user directly back to their cart on your store

  • modifiedDate
    The date when the cart was last modified.

Line items fields

As per the example above, there can be one or more line items. All items in the basket should be included.

  • sku
    The identifier for the line item

  • name
    The item name or basic description

  • description
    A more detailed description of the item

  • category
    The category the product falls under, e.g. T-Shirts > Blue

  • other
    This can be anything you like, or left blank if not required

  • unitPrice
    The full unit price of the item

  • salePrice
    The price the item is sold for on your store

  • quantity
    The number of items

  • totalPrice
    The total price of items (taking sale price and quantity into account)

  • imageUrl
    The full URL to an image of this product

  • productUrl
    The URL of the product on your website

Including these on your site

The above tracking and cart tracking scripts should appear on every page of your site, where possible.

You should also include the 'identify' script as soon as you know who the current user is. You don't then have to include this on every page, but it will not affect anything if you do.

Working with single-page apps

If your site is a single-page app, or, at least, parts of it are, then you'll have to do a little more work to get all this functioning.

As above, you will need to include the tracking script on the page before any calls to our servers are made. And, as above, you will need to identify the user at the first possible opportunity.

The main cart tracking code, however, should be called as often as is sensible. This could be, for example, every time the user clicks something on the site, or it may just be whenever the cart is updated.

The important thing to note is that when this code is executed, our clocks start ticking. So if you have the 'abandoned cart' email being sent after 20 minutes, then we will send the email if we have not heard from the site after 20 minutes.

The point is, if your site does not send through this data often enough, it could mean that we send out the email prematurely.

Did this answer your question?