E-commerce
Connect the Widget with your online store.
If you run an online store, the Widget can connect conversations with what your customers view and buy, and keep your store cart in sync with products the AI Agent adds in the conversation.
Everything on this page extends the Widget setup. Pass the options and callbacks in the configuration object of ZowieWidget.init, and call the methods on the global ZowieWidget object after the Widget has loaded.
Sync the cart from the conversation
When the AI Agent adds products to the cart or removes them in the conversation, the Widget calls onCartItemsModified with the list of changes. Use it to update the cart on your website with your store's own cart API.
ZowieWidget.init("<your-instance-id>", {
onCartItemsModified: (items) => {
const added = items.filter((item) => item.modificationType === "Added");
const removed = items.filter((item) => item.modificationType === "Removed");
added.forEach((item) => myStore.cart.add(item.productId, item.quantity));
removed.forEach((item) => myStore.cart.remove(item.productId, item.quantity));
},
});Without this callback the cart still works inside the conversation, but your website's cart doesn't change.
E-commerce tracking
E-commerce tracking connects conversations with what customers view and buy in your store. Your TAM sets it up for your store platform.
- Shopify, BigCommerce, Magento and nopCommerce: the Widget tracks product visits and the cart automatically. To turn off automatic cart tracking, set
ecommerceCartWatchEnabled: false. - Other stores: report events yourself with
trackVisitedProduct,trackCartUpdatedandtrackPurchased.
The tracking methods do nothing when tracking is off for your website.
ZowieWidget.trackVisitedProduct({
productId: "8123",
title: "Wireless Headphones",
price: 79.99,
currency: "USD",
shopUrl: "https://shop.example.com/products/wireless-headphones",
imageUrl: "https://shop.example.com/images/8123.jpg",
});
ZowieWidget.trackPurchased({
orderId: "ORD-1042",
lineItems: [{ productId: "8123", variantId: "8123-black" }],
totalAmount: 79.99,
currency: "USD",
});Options
| Option | Type | Default | Description |
|---|---|---|---|
trackingEnabled | boolean | Set by Zowie | Turn tracking on or off on this website. |
ecommerceCartWatchEnabled | boolean | true | Let the Widget watch the store cart automatically on Shopify, BigCommerce, Magento and nopCommerce. |
Callbacks
| Callback | Arguments | Called when |
|---|---|---|
onCartItemsModified | items: CartModifiedItem[] | The AI Agent added products to or removed them from the cart in the conversation. See CartModifiedItem. |
onEcommerceProductVisited | None | The customer visited a product page. Shopify, BigCommerce, Magento and nopCommerce only. |
onEcommercePurchased | total: number, currency: string | The customer completed a purchase. BigCommerce, Magento and nopCommerce only. |
Methods
| Method | Description |
|---|---|
trackVisitedProduct(product) | Report a product page visit. See VisitedProduct. |
trackCartUpdated(lineItems) | Report the current cart content. See LineItem. |
trackPurchased(purchase) | Report a completed purchase. See Purchase. |
updateEcommerceCart() | Read the cart again on Shopify stores, for example after your own code changed it. |
Types
CartModifiedItem
| Field | Type | Description |
|---|---|---|
productId | string | ID of the product variant. |
quantity | number | Number of items added or removed. |
modificationType | "Added" | "Removed" | Whether the items were added or removed. |
product | object | Product details shown on the product card in the conversation. |
VisitedProduct
| Field | Type | Required | Description |
|---|---|---|---|
productId | string | Yes | Product ID. |
title | string | Yes | Product name. |
price | number | Yes | Product price. |
currency | string | Yes | Currency code, for example USD. |
shopUrl | string | Yes | URL of the product page. |
imageUrl | string | No | URL of the product image. |
category | { id: string, name: string } | No | Product category. |
LineItem
| Field | Type | Required | Description |
|---|---|---|---|
productId | string | Yes | Product ID. |
variantId | string | Yes | Product variant ID. |
title | string | Yes | Product name. |
price | number | Yes | Price of one item. |
currency | string | Yes | Currency code, for example USD. |
quantity | number | Yes | Number of items in the cart. |
shopUrl | string | Yes | URL of the product page. |
imageUrl | string | No | URL of the product image. |
Purchase
| Field | Type | Required | Description |
|---|---|---|---|
orderId | string | Yes | Order ID. |
lineItems | { productId: string, variantId: string }[] | Yes | Purchased products. |
totalAmount | number | Yes | Total order value. |
currency | string | Yes | Currency code, for example USD. |
subtotalAmount | number | No | Order subtotal. |
discountAmount | number | No | Discount amount. |
taxAmount | number | No | Tax amount. |
shippingCostAmount | number | No | Shipping cost. |
Updated about 2 hours ago