Used for:
- Message Content
- Building an Audience
- Analytics
Cart Items Overview
Cart items consist of data about the items that were placed in a cart from a visitor on your website. They are stored with each contact in the contacts collection along with contact attributes and list membership. Cart items are normally passed using the JavaScript listeners cartitem method on your website, but they can also be passed using the cartitems API call. Regardless of the method used, you are able to pass certain info about the cart item such as productID, sku, category, image urls, etc.
Cart times can be used to build audiences and analytics reports, as well as personalize message content. For example, you could create an audience of contacts with items in their cart from the shirt category where the total value is greater than $40. Then you could use Smarty to display items from the cart in a message.
Example audience rule using cart items:

Example message content displaying cart items:

Learn about creating an abandon cart automated message.
How Cart Items Are Stored
Cart item data is stored as a JSON object in the contact record. Below is an example of a contact record containing the cart item object. We have highlighted the cart item object for easier visualization.
[{ "channels": { "email": { "address": "fredgarvin@example.com", "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": "https://cordialthreads.myshopify.com/?exitintent", "images": [ "https://cdn.shopify.com/s/files/1/1070/1848/products/3705707-p-MULTIVIEW.jpg?v=1470290687" ], "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" }]
The above example shows the contact record containing the cartitems object. Note how 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.
Learn more about the cart item schema and parameters in the API documentation.
How Cart Items Are Created
Cart item data is created by either JavaScript listeners on a website or via an API call.
How to 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 (if the contact being previewed has items in their cart):
{$utils->jsonPrettyPrint($contact.cart.cartitems)}
Using 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 the items is currently in their cart.
For example, you can use the following code to display the items currently in a contact's cart (if 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}">{$item.name}</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>
{/foreach}
Learn about creating an abandon cart automated message.
Building Audiences Using Cart Items
Using the Cart Items audience rule, you are able to build audiences based on the items in a contact's cart.
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 on the Gold list that have more than $40 in their cart.
Note below the Cart Items audience rule highlighted on the audience builder:

Learn more about the audience builder
Building 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
Using audience trend reports, you can view the population of an audience over time based on if there are items in a contact's cart.
For example, 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.

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.
For example, 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 reports allow you to view reports of event activity. You are able to filter reports using audience rules much the same as event dashboards. For example you can filter by a saved audience rule where the contact has items in their cart.

In the next article learn about events.
Comments
0 comments
Please sign in to leave a comment.