How can we help?

Cart items


Cart items consist of data about items placed in the shopping cart by visitors on your website. These items are stored with each contact in the Cordial contacts collection along with contact attributes and list membership. You can use cart items to build audiences, analytics reports, and personalize message content.

Cart items are normally passed using the JavaScript Listeners cart item method on your website. They can also be passed using the cart items API call. Regardless of the method, you can pass information about cart items such as productID, sku, category, image urls, and much more.

How Cordial stores cart items

Cart item data is stored as a JSON object in the contact record. Below is an example of a contact record containing a cart item object.

The cart item contains the required fields of productID, sku, category, and name along with the optional fields of description, price, url, and images. Amount totals are calculated automatically.

	"channels": {
		"email": {
			"address": "",
			"subscribeStatus": "subscribed",
			"unsubscribedAt": ""
	"gender": "Male",
	"last-name": "Fred",
	"first-name": "Garvin",
	"cart": {
		"cartitems": [{
			"productID": "About Last Night",
			"sku": "26616383623",
			"category": "shirts",
			"name": "Back Off Polo",
			"qty": 2,
			"description": "Robert Graham - Back Off Polo Your style goes around and around! Classic styling Clean lines Brand mark logo on center 50% 50% mix Washable Imported. Measurements: Length: 10 Product measurements were taken using size MD. Please note that measurements may vary by size.",
			"itemPrice": 98,
			"url": "",
			"images": [
			"amount": 98,
			"properties": {
				"custom_key": "custom_value"
		"totalAmount": 98,
		"lm": "2018-03-28T18:13:06+0000"
	"_id": "58d2fc99ac0c8117814d4e78",
	"lastModified": "2017-03-22T22:37:13+0000",
	"createdAt": "2017-03-22T22:37:13+0000"

How Cordial creates cart items

Cart item data is created in Cordial by either JavaScript Listeners on your website or via an API call.

View cart items

Cart item data is viewable in the API or by rendering cart items in a message using Smarty.

View cart items using the API

To view cart item data in the API, use the GET /contacts or GET /contacts/{primary_key} API calls.

View cart items in a message preview

The following Smarty will render cart items (in JSON format) within a message, given that the contact being previewed has items in their cart.


Use cart Items for message content

With Smarty, you can render cart items in a message using the foreach statement. This is useful in an abandon cart campaign when you want to show contacts what items are currently in their cart.

You can use the following code to display the items currently in a contact's cart (given that the cart data exists in the system).

You left the following items in your cart:<br> 

{foreach $contact.cart.cartitems as $item}
<b><a href="{$item.url}">{$}</a></b><br>
SKU: {$item.sku}<br/> Description: {$item.description}<br>
Qty: {$item.qty}<br/> Price: {$item.amount}<br><br>
<a href="{$item.url}"><img src="{$item.images.0}" /></a><br>

Below is an example of rendered message content displaying a user's cart items.

Build audiences using cart items

Using the Cart audience rule, you can build audiences based on the items in a contact's cart.

1. Navigate to Contacts > Audience and edit or create a new audience.

2. Select Cart from the Rules dropdown in the Audience Builder.

Use case

You can create complex segmentation queries by combining cart item audience rules with other rules to create queries such as: Show me all male contacts that have put more more than $40 of Awesome Flannel in their cart within the past 30 days.

Build analytics reports using cart items

Audiences based on items in a cart can be saved as audience rules and either visualized over time with Audience Trend reports or used as filters for event data dashboards and event data reports.

Audience Trend reports

To access Audience Trend reports, log in to Cordial and navigate to Analytics > Audience Trends

Use case

You can create an audience based on if a contact has items in their cart, enable Audience Trend analytics on the audience rule, then view the population over time on an Audience Trends chart. The below example shows an audience of men who've added flannel to their shopping cart.

Filter event dashboards

Event dashboards provide a way to visualize event activity over time by creating customizable charts. You can take advantage of cart items in event dashboard charts using audience filters.

To edit an event chart (also called a time series chart), navigate to Analytics > Event Dashboards and select Chart Settings in the upper right corner of the chart.

Use case

You can create a chart that plots message activity over time filtered by a saved audience rule where the contact has items in their cart.

Filter Event Data Reports

Event data reportsnavigation: Analytics > Event Data Reportsallow you to view reports of event activity. You can filter reports using audience rules similar to the event dashboard charts.

Use case

You can filter by a saved audience rule where the contact has items in their cart.


In the next article, you can learn about events.



Please sign in to leave a comment.