Sync Cart
Updates the current cart state.
This event is madatory for:
- The Exclude items currently in cart filter, and must be fired upon every page load.
- Reconnect implementation.
Parameters
- name: Human-readable name, not used to identify an event type
- properties: A container for the event properties as specified in the following table:
Property | Description | Type |
---|---|---|
dyType | Must be "sync-cart-v1". | String |
value | The total monetary value of the event (value of the total cart contents, not just the item that triggered the event); in the actual payment currency. | Float (dollars.cents). Numbers are rounded to the nearest 0.01. Numbers smaller than 0.005 are rounded down to 0. |
currency Optional, but required for multi-currency sites | The currency used for the value (if other than the default currency) | String List of supported currencies |
cart | The cart's absolute current state, including the last item added. Products are ordered from the first added to the cart to the most recent. | Object See the cart property table that follows for details. |
Cart object properties:
Property | Description | Type |
---|---|---|
productId | SKU exactly as it appears in the product feed | String |
quantity | Number of items | Number |
itemPrice | The price of the item added | Float in the format: dollars.cents |
Example: Implementation via script
DY.API("event", {
name: "Sync cart",
properties: {
dyType: "sync-cart-v1",
value: 125.50,
currency: "any supported currency code", // Optional non-default currency used
cart: [ //Mandatory, the order of products should be from oldest to newest
{
productId: "sku-4324-bg",
quantity: 2,
itemPrice: 12.34,
},
{
productId: "item-34454",
quantity: 1,
itemPrice: 34.45
}
]
}
});
Example: Implementation via Experience API (server-side)
"events":[
{
name: "Sync cart",
properties: {
dyType: "sync-cart-v1",
value: 125.50,
currency: "any supported currency code", // Optional non-default currency used
cart: [ //Mandatory, the order of products should be from oldest to newest
{
productId: "sku-4324-bg",
quantity: 2,
itemPrice: 12.34,
},
{
productId: "item-34454",
quantity: 1,
itemPrice: 34.45
}
]
}
} ]
Go to the API reference for the Events endpoint to learn more.
Updated 2 months ago
Further Reading
See the [API reference for the Events endpoint] (/reference/reporting-events-api) for more information.