Skip to main content

Tracking Abandoned Cart

Under active development

This feature is currently under active development and not ready for wide release. If you are interested, please reach out to us at at support@spektrix.com

This guide outlines how to enable Abandoned Cart tracking on your website.

Once installed, this setup allows Dotdigital to track users who begin but don’t complete a purchase, and trigger personalised reminder emails through an automated program.

How it works

The spektrix-basket-summary web component already reads the contents of the customer's basket. When Dotdigital Basket Insights is enabled on the component, it also pushes identity and basket data into the data layer as the basket changes.

The Dotdigital tag — loaded through Google Tag Manager — reads those events and sends them to Dotdigital, where you build the abandoned cart program.

You do not need to write any tracking logic yourself. The mapping from Spektrix basket data to the Dotdigital schema is handled by the component.

Setup

There are three parts to the setup:

  1. The Basket Summary web component, configured for Basket Insights
  2. An attribute in Spektrix marking which items may appear in abandonment emails
  3. Setup the connection in Dotdigital
  4. Google Tag Manager, to load the Dotdigital tag

1. Basket Summary Web Component

Many clients already have this step implemented if they are already using the basket-summary web component. If so, you only need to add the two Basket Insights Attributes described below.

Identify whether the Basket Summary web component is already implemented

To identify whether the Basket Summary web component is already implemented, check whether spektrixBasket appears in developer tools > Application > Local Storage. If it does, the component is running.

This component does not need to be rendered on the page, it just needs to be running in the background to capture basket data. So you can either implement the full component, including the markup, and display the basket summary to the end customer as per documentation, OR you can implement the minimum as outlined below.

Loading code

Between the <head> tags of your page, ensure you have the following script which defines the custom element. If you are already using any of the Spektrix web components, you should already have this in place:

<script src="https://webcomponents.spektrix.com/stable/spektrix-component-loader.js" async></script>

Loading the web component

You will need to change the client-name and custom-domain to match those of your client's. Optionally, you can populate the component with markup to display the basket summary, as per documentation.

<spektrix-basket-summary
client-name="thetheatre"
custom-domain="tickets.thetheatre.org"
dd-basket-insights-active
dd-basket-insights-cart-url="https://www.thetheatre.org/checkout">
</spektrix-basket-summary>

Basket Insights attributes

AttributeRequiredTypePurpose
dd-basket-insights-activeYesBooleanTurns on the Dotdigital Basket Insights data layer pushes. Present means on; omit the attribute to turn it off.
dd-basket-insights-cart-urlYesStringThe URL used for the "return to cart" link in your abandonment emails. This should be a page on your site that loads the Spektrix basket.
warning

The component must be present on every page where a customer can add to or change their basket, including the pages hosting your Spektrix iframes. If it is missing from a step in the purchase path, changes made on that step will not be tracked.

2. Mark items for inclusion

Items are only sent to Dotdigital if they have been explicitly opted in. This gives you control over which shows and products can appear in a reminder email.

In Settings in Spektrix, create a Check-box attribute named exactly:

Include In Abandoned Email

Then tick that Attribute in Admin on each Event and Merchandise item you want included.

Supported item types

The first release supports Event tickets and Merchandise only. Donations, memberships, gift vouchers and ticket subscriptions are not included in the basket data sent to Dotdigital. Baskets containing these items will still be tracked — those items are simply omitted from the products list.

3. Dotdigital setup

Dotdigital Tag ID

In Dotdigital, navigate to:

Connect > Connect Website > New connection

The following settings need to be configured:

SettingValue
Website NameYour website URL
DomainsAdd both your website domain and your custom iframe domain
Enable Web behavior trackingYes
Enroll abandoned carts toThe program you build
Enroll abandoned carts afterUser's choice
Require cookie consentNo
Track order insights from purchaseComplete eventsNo
Automatic page trackingYes

Once this is done, take note of the Unique/Tag ID listed for this connection: you don't need to copy it down now but you will need it for the Google Tag Manager setup below.

Abandoned cart program

Build the program that sends your reminder email in Dotdigital, using its Basket Insights triggers.

The delay before a customer enters the program, and the content of the email, are both set in Dotdigital. You do not need to pass a Program ID or a delay to Spektrix or to Google Tag Manager.

You do not need to activate the program until you're ready to start sending emails.

4. Google Tag Manager (GTM)

If GTM is already installed on your website, you can import the pre-configured container into your existing setup. If GTM is not installed on your website, follow the available resources provided by Google on setting up and installing Google Tag Manager. Because the component now builds the Dotdigital payload itself, the container only needs your Dotdigital Tag ID. Delay, program selection and campaign content are all configured directly inside Dotdigital.

1. Download the Standard Template

Download the full GTM template file below:

Download the Dotdigital Tracking GTM Template

2. Import the Container

  1. Log in to Google Tag Manager.
  2. Go to Admin > Import Container.
  3. Select the GTM-Template-Dotdigital-v6.json file you just downloaded.
  4. Choose your workspace.
  5. Import Option:
    • Select Overwrite if this is a new container (WARNING: this deletes existing tags).
    • Select Merge if you have existing unrelated tags (recommended).
  6. Click Confirm.

3. Configure Standard Variables

  1. Go to Variables > User-Defined Variables.
  2. Edit the following variable:
Variable NameDescriptionAction
Dotdigital Account IDUnique tracking ID (e.g., DM-0334192456-01).Found in Dotdigital under Connect > Connect website > Unique ID.

Data Layer Reference

You do not need to read this section to complete the setup. It is provided so developers can verify the integration and debug it in GTM Preview mode.

Every payload is namespaced under spektrixDD, and each push is preceded by { ecommerce: null, spektrixDD: null } to clear stale values from GTM's merged data layer state.

Data Layer Events

spektrix.ddIdentify

Pushed when a signed-in customer is detected. It is deduplicated by email address, so it only fires again if the signed-in customer changes.

{
event: 'spektrix.ddIdentify',
spektrixDD: {
email: 'john@doe.com',
firstName: 'John',
lastName: 'Doe',
mobileNumber: '+447700900000'
}
}

spektrix.ddCartUpdate

Pushed whenever the contents of the basket change. Unchanged and empty baskets are skipped.

{
event: 'spektrix.ddCartUpdate',
spektrixDD: {
cartId: 'a1b2c3d4-...',
currency: 'GBP',
subtotal: 45.00,
grandTotal: 40.00,
cartUrl: 'https://www.thetheatre.org/checkout',
products: [
{
sku: '2603_event',
productId: '2603_event',
name: 'Romeo and Juliet',
description: '<html>...',
categories: ['Tickets'],
unitPrice: 25.00,
quantity: 2,
totalPrice: 50.00,
imageUrl: 'https://...',
productUrl: 'https://www.thetheatre.org/whats-on/romeo-and-juliet'
}
]
}
}

spektrix.ddPurchaseComplete

Pushed on order confirmation, so that Dotdigital can close the cart and suppress the reminder email. It repeats the last cart payload and adds the Spektrix transaction ID as orderId.

{
event: 'spektrix.ddPurchaseComplete',
spektrixDD: {
cartId: 'a1b2c3d4-...',
currency: 'GBP',
subtotal: 45.00,
grandTotal: 40.00,
cartUrl: 'https://www.thetheatre.org/checkout',
products: [ ... ],
orderId: 'TXN-12345'
}
}

Object Shapes

Cart fields

FieldDescription
cartIdIdentifier that groups related cart updates together. It is stored in local storage on a 72 hour sliding window and is reset once an order is confirmed.
currencyYour Spektrix system currency, e.g. GBP.
subtotalBasket total before discounts.
grandTotalBasket total after discounts.
cartUrlThe value of dd-basket-insights-cart-url.
productsThe opted-in items in the basket.
orderIdSpektrix transaction ID. Present on spektrix.ddPurchaseComplete only.

Product fields

FieldDescription
skuItem identifier, e.g. 2603_event.
productIdSame value as sku.
nameEvent or merchandise item name.
descriptionThe item description from Spektrix.
categoriesArray containing the item's category, e.g. ['Tickets'].
unitPricePrice of a single item.
quantityNumber of that item in the basket.
totalPriceunitPrice multiplied by quantity.
imageUrlThe item's image in Spektrix, if one is set.
productUrlThe item's Web URL in Spektrix, if one is set.

Items that share the same sku and unitPrice are condensed into a single product entry with the quantity and total price aggregated.

Item types

Basket itemSKU formatCategory
Event tickets{EventID}_eventTickets
Merchandise{StockItemID}_merchandiseMerchandise

The Dotdigital tracking must only run after the user has accepted tracking cookies. To be GDPR compliant, you must get consent from your users if your site uses any non-essential cookies. Using Google Tag Manager means that all analytics behavior will respect a customer's choice but it will not implement this behavior. You can do this with a cookie management solution and can find our details on cookies here.

Known limitations

  • Item types. Only Event tickets and Merchandise are sent in the first release.
  • Opt-in required. Items without the Include In Abandoned Email attribute ticked will not appear in abandonment emails.