Cart viewed
Record when a user views a shopping cart.
This event tracks when a user views their shopping cart on an online store.
Track this event whenever a user views the shopping cart page or summary.
Implementation
Here is an example of how to track this event:
import croct from '@croct/plug';croct.track('cartViwed', {cart: {currency: 'USD',total: 899.99,items: [{index: 0,product: {productId: '12345',name: 'Black iPhone 12',displayPrice: 899.99},quantity: 1,total: 899.99}]}});
Input properties
These are the supported properties:
- cartobject
The shopping cart being viewed.
- currencystring
The currency in which the monetary values are expressed in the shopping cart, such as "USD" or "EUR".
We recommend using the 3-letter currency codes defined by the ISO 4217 standard. For currencies having no official recognition in the standard, consider using ISO-like codes adopted locally or commercially, such as "XBT" for BitCoin.
- itemsarray<object>
The list of items in the shopping cart.
- indexnumber
The position of the item in the shopping cart, starting from 0.
This value typically represents the order in which the items were added to the cart. For example, the first item has an index of 0, the second item has an index of 1, and so on.
The index must be non-negative and unique within the shopping cart.
- productobject
The product in the cart.
- productIdstring
The ID that uniquely identifies the product on your store. For example, "3108" or "CD4371".
The value must be between 1 and 50 characters long.
- sku(optional)string
The SKU of the product. For example, "IPH-GRE-64", "153-169-172-182887".
The value must be between 1 and 50 characters long.
- namestring
The name of the product. For example, "iPhone" or "Nike Air Max".
The value must be between 1 and 200 characters long.
- category(optional)string
The category of the product. For example, "Smartphones" or "Running shoes".
The value must be between 1 and 100 characters long.
- brand(optional)string
The brand of the product. For example, "Apple" or "Nike".
The value must be between 1 and 100 characters long.
- variant(optional)string
The variant of the product, such as size, color and style. For example, "Black", "M", "XL".
The value must be between 1 and 50 characters long.
- displayPricenumber
The price of the product displayed in the store. For example, 899.99.
The value must be non-negative.
- originalPrice(optional)number
The regular price of the product before any discounts. For example, 999.99.
The value must be non-negative.
- url(optional)string
The URL of the product page.
- imageUrl(optional)string
The URL of the product image.
- productId
- quantitynumber
The number of units of the item.
The value must be greater than or equal to 1.
- discount(optional)number
The amount of the discount applied to the item.
The value must be non-negative.
- coupon(optional)string
The coupon applied to the item. For example, "SUPER_DEALS".
The value must be between 1 and 50 characters long.
- totalnumber
The total for the item, including discounts and any other adjustment.
The value must be non-negative.
- index
- subtotal(optional)number
The total of all items and quantities in the shopping cart including applied item promotions.
The value must be non-negative.
- shippingPrice(optional)number
The total shipping price for the items in the shopping cart, including any handling charges.
The value must be non-negative.
- taxes(optional)object
The taxes associated with the transaction.
It must be expressed as a dictionary where the key is the tax name (up to 50 characters) and the value is the tax amount (non-negative).
Example:
{"state": 3.1,"local": 1.5}- costs(optional)object
The costs associated with the transaction, such as manufacturing costs, shipping costs not paid by the customer, or other costs.
It must be expressed as a dictionary where the key is the cost name (up to 50 characters) and the value is the cost amount (non-negative).
Example:
{"manufacturing": 5.0,"packaging": 2.0}- discount(optional)number
The amount of discount applied to the shopping cart, as an absolute value. For example, 10.00 for a $10 discount.
The value must be non-negative.
- coupon(optional)string
The coupon applied to the shopping cart. For example, "SUPER_DEALS".
The value must be between 1 and 50 characters long.
- totalnumber
The total revenue or grand total associated with the transaction, including shipping, tax, and any other adjustment.
The value must be non-negative.
- lastUpdateTime(optional)number
The last time the shopping cart was updated in milliseconds since the Unix epoch.
If not specified, the SDK considers the time at which you tracked the event to be the last update time.
- currency
Processed properties
This event has no processed properties.
Payload examples
Below are some payload examples for this event:
{"cart": {"currency": "USD","total": 899.99,"items": [{"index": 0,"product": {"productId": "12345","name": "Black iPhone 12","displayPrice": 899.99},"quantity": 1,"total": 899.99}]}}