If your D·engage account is an eCommerce account, you should use standard eCommerce events in the SDK. If you need some custom events or your account is not a standart ecommerce account, you should use custom event functions.
Events for Ecommerce Accounts
There are standart ecommerce events in D·engage SDK.
- Shopping Cart Events
- Add to Cart
- Remove from Cart
- Delete Cart
- Begin Checkout
- Order Events
- Order
- Cancel Order
- Wishlist Events
- Add to Wishlist
- Remove from Wishlist
- Search Event
For these events there are related tables in your account.
Shopping Cart Events
These events will be stored in shopping_cart_events table.
There are 4 shopping cart event functions. addToCart, removeFromCart, deleteCart, beginCheckout
Every shopping cart event function needs all items in the cart as an array. You must send the last version of the shopping cart.
For example: If there is one item in the cart and the item id is 5. And after that, an add to cart action is happened with item id 10. You have to send 10 as product_id in event parameters and you must send the current version of cart items. Meaning [5, 10]
// All items currently exists in shopping cart
var cartItems = [
{
product_id: '123',
product_variant_id: '1222',
quantity: 1,
unit_price: 1233,
discounted_price: 123
},
{
product_id: '123',
product_variant_id: '1222',
quantity: 1,
unit_price: 1233,
discounted_price: 123
}
];
// Add to cart event
dengage('ec:addToCart', {
product_id: '123',
product_variant_id: '1222',
quantity: 1,
unit_price: 1233,
discounted_price: 123,
// ... extra columns in shopping_cart_events table, can be added here
cartItems: cartItems,
});
// Remove from cart event
dengage('ec:removeFromCart', {
product_id: '123',
product_variant_id: '1222',
quantity: 1,
unit_price: 1233,
discounted_price: 123,
// ... extra columns in shopping_cart_events table, can be added here
cartItems: cartItems,
});
// view cart event
dengage('ec:deleteCart', {
// ... extra columns in shopping_cart_events table, can be added here
});
// begin checkout event
dengage('ec:beginCheckout', {
// ... extra columns in shopping_cart_events table, can be added here
cartItems: cartItems,
});
Order Events
Orders events will be sent to order_events and order_events_detail tables.
// Ordered items or canceled items
var cartItems = [
{
product_id: '123',
product_variant_id: '1222',
quantity: 1,
unit_price: 1233,
discounted_price: 123,
// ... extra columns in order_events_detail table, can be added here
},
{
product_id: '123',
product_variant_id: '1222',
quantity: 1,
unit_price: 1233,
discounted_price: 123,
// ... extra columns in order_events_detail table, can be added here
}
];
dengage('ec:order', {
order_id: '123',
item_count: 123, // total ordered item count
total_amount: 1, // total price
discounted_price: 123, // use total amount if there is no discount
payment_method: 'credit_card', //credit_card / debit_card / mobile_payment / bank_transfer / prepaid_card / crypto / cod / online_payment / other
coupon_code: '', // use if necessary
// ... extra columns in order_events table, can be added here
cartItems: cartItems, //ordered items
});
dengage('ec:cancelOrder', {
order_id: '123', // canceled order
item_count: 123, // canceled total item count
total_amount: 1, // canceled item's total price
discounted_price: 123, // use total price if there is no discount
// ... extra columns in order_events table, can be added here
cartItems: cartItems, // canceled items
});
Search Event
Search events will be stored in search_events table.
dengage('ec:search', {
keywords: 'hello', // text in the searchbox
result_count: 123,
filters: '', //use can send extra filters selected by user here. Formating is not specified
// ... extra columns in search_events table, can be added here
});
Wishlist Events
These events will be stored in wishlist_events.
There are 2 wishlist event functions. addToWishlist, removeFromWishlist.
You can use this event for tracking favorites, shopping lists, price drop alert lists or back-in-stock lists.
For this purpose you should use list_name property.
Possible values: favorites / shopping_list / price_drop_alert / back_in_stock_alert ...
dengage('ec:addToWishlist', {
list_name: 'favorites', // favorites / shopping_list / price_drop_alert / back_in_stock_alert ...
product_id: '123',
product_variant_id: '123', // optional
expire_date: '2022-01-01T00:00:00.000Z', // optional (mostly for price_drop_alert / back_in_stock_alert
price: '1.5', // optional (it is necessary for price drop campaigns)
discounted_price: '1.5', // optional
stock_count: 0 // optional (it is necessary for back-in-stock campaigns)
// ... extra columns in wishlist_events table, can be added here
});
dengage('ec:removeFromWishlist', {
list_name: 'favorites', // favorites / shopping_list / price_drop_alert / back_in_stock_alert ...
product_id: '123',
// ... extra columns in wishlist_events table, can be added here
});