Skip to main content

Tracking cart changes

Cart changes can be tracked either with the Voyado Engage tracking script or the tracking API. Engage can trigger abandoned cart communication to be sent to identified contacts. To enable this, Engage need to know:

  • Every update of every unique shopping cart

  • The contactId of the visitor

There are two methods to consider when tracking cart changes:

  • cart(): Used for registering visitor actions related to any cart modification

  • emptyCart(): Used for pruning the cart of all items, usually when indicating a purchase or logout by the e-com visitor

Data flow

This is how the flow looks:

  1. The site submits shopping cart changes, either via the tracking script implemented on the e-com site or through the tracking API.

  2. Carts containing products that haven't been accessed for at least 30 minutes are considered abandoned. If the cart is connected to a specific contact it will be sent to Engage. All other carts will be filtered out.

  3. Engage then triggers the relevant automation (based on language/locale).

Cart automation requirements

The following are required so that an abaondoned cart automation can be triggered:

  • The locale must match a product feed in Engage and the corresponding language is set in an automation.

  • The SKU/SKUs must match products in the product feed (commonly “g:id”). If a SKU doesn’t match the feed, that particular product will not be included in the email. If no SKUs match the products in the feed the automation won't be triggered at all.

  • No products in the cart have been purchased (meaning no transaction has been sent to Engage) since the cart was identified as abandoned (although this can be overruled when configuring the trigger).

Using the tracking script

Here is how to use the tracking script to track cart changes.

The cart() method

Invoke this method every time the cart is changed (items added/removed or the quantity updated) regardless of if the user has been identified by the website or not. The cart() method will then generate a HTTP POST request to the Collect endpoint.






Cart identifier, must be unique for each cart



URL to the cart



Engage contact ID, cookie _vaI will be used as fallback



Locale for the site where the cart is (example sv-SE). Format as defined by IETF language tag. Only locales with a Product Feed assigned in Engage can trigger an abandoned cart automation



The array of items added to the cart



Item ID (SKU in Engage)



The number of items

Fields marked with * are mandatory

This is what a cart update loooks like in code:

        "itemId": "456436",
        "quantity": 2,
        "itemId": "456437",
        "quantity": 2,
}); <!-- Adds two products in the cart-->

The emptyCart() method

Invoke this method when the cart has been emptied, either manually by the user or when the checkout process has been completed. This method is equivalent to invoking cart() with no items. It’s important to invoke emptyCart() after each successful checkout to avoid faulty abandoned cart communications.

The emptyCart() method will generate a HTTP POST request to the Collect endpoint.






Cart identifier



The contact's Engage ID

Fields marked with * are mandatory

This is how a call to emptyCart() looks in code:

    "cartRef":  "354354"}

Using the tracking API

It's possible to submit cart changes directly via the API instead of implementing the tracking script. If you choose this approach, it is important to identify all contacts that come to the e-com via links in emails (add “vtid” in “contactId”).

Corresponding functionality is exposed via REST API:s, see API documentation explaining the calls here. Calls can be tested through OpenAPI (Swagger).

The link to this endpoint would be: [tenantname]

Important points when tracking cart changes

Here are the most important points to keep in mind:

Call the “cart()” script method or Carts API regardless of whether the user is anonymous/identified or logged in or not. All behavioral data can be used to build understanding and insights. A shopping cart belonging to an anonymous user can be linked to a contact afterwards when they are identified.

Call the “cart()” script method or Carts API for all updates to the shopping cart, regardless of where or at what stage on the site the update takes place (product page, popup, checkout, etc). Engage handles the shopping cart based on its latest change. It is therefore important that all changes to the shopping cart generate a call to “cart()” or the Carts API and that the data corresponds to the shopping cart that is displayed on the website.

“cartRef” must be unique and must not be shared between different baskets or users. cartRef is the unique identifier for a shopping cart, the same cartRef may not be used for any other shopping carts. A cartRef of a specific shopping cart must not be changed, all updates regarding a shopping cart must have the same cartRef.

Include “cartRef” for empty carts as well. Even empty carts should have a cart reference.

Make sure to only call “cart()” script method or Carts API when the cart is updated. Otherwise, you will pollute your data in Engage.

Call the “cart()” script method or Carts API with a “locale” corresponding to the locale of your Product Feed in Engage. In order for the products in a cart to be enriched with article data, a Product Feed for the same language needs to be set up in Engage. An automation with the same locale language also needs to be active.

Abandoned carts: All carts that will not be emptied before the website visitor leaves or makes a purchase risk being marked as abandoned. If you have an abandoned cart automation active it will be triggered by the unemptied carts.