E-commerce data tracking via Web API

Track user events and properties from the backend of your website

To launch triggered e-commerce campaigns, you'll need to track viewing items, adding items to the shopping cart, making an order, etc.

User properties will appear on the left field of the user's card, and user events will appear in its history. Learn more about properties and events in this article.

Here are some examples of code snippets that will send the required data to Dashly.

Events and properties of viewing an item

This code should run when a visitor is visiting an item page:

dashly.track('$product_viewed, {
    "$name": name_selector,
    "$url": url_selector,
    "$amount": amount_selector,
    "$img": img_selector,
});
dashly.identify([
    {op: "union", key: "$viewed_products", value: name_selector}
]);

Events and properties of adding an item to a cart

This code should run when a visitor is adding an item to a cart:

dashly.track('$cart_added', {
    "$name": name_selector,
    "$url": url_selector,
    "$amount": amount_selector,
    "$img": img_selector,
});
dashly.identify([ 
    {op: "add", key: "$cart_amount", value: amount_selector},
    {op: "union", key: "$cart_items", value: name_selector}
]);

Events and properties of payment confirmation

If your website has an online payment option, this code should run when a user is entering the payment success page:

dashly.track("$order_paid", {
    "$order_id": order_id
});

Events and properties of the checkout process

The following code should run when one is entering the checkout page:

dashly.track("$order_started"); 

This code should run when one enters the order success page:

dashly.track("$order_completed", {
    "$order_id": order_id, 
    "$order_id_human": order_id_human, 
    "$order_amount": order_amount
}); 
dashly.identify([ 
    {op: "delete", key: "$cart_items", value: 0 },
    {op: "delete", key: "$viewed_products", value: 0 },
    {op: "delete", key: "$cart_amount", value: 0, 
    {op: "add", key: "$orders_count", value: 1}, 
    {op: "add", key: "$revenue", value: order_amount},
    {op: "update_or_create", key: "$last_payment", value: order_amount} 
]);
Powered by