Cart & Checkout Event API
E-commerce sites can trigger events for revenue analytics to get insights into what purchases are being driven by Alhena
Once you install the Alhena Chat Widget snippet on your site, two global methods become available on window.gleenWidget
:
sendCartEvent(data)
sendCheckoutEvent(data)
Use these methods to report e‑commerce cart and checkout actions so you can attribute revenue back to your chat widget interactions.
sendCartEvent(data)
Report when the user adds, removes, or updates items in their cart.
Data properties
type (string, required) One of:
"ITEM_ADDED"
"QUANTITY_INCREASED"
"QUANTITY_DECREASED"
"ITEM_REMOVED"
productId (string, required) — Your internal product identifier
productName (string, required) — Human‑readable name
value (number, required) — Price after discounts
currency (string, required) — ISO 4217 currency code (e.g.
"USD"
)quantity (number, required) — Quantity after the action
Example:
window.gleenWidget.sendCartEvent({
type: 'ITEM_ADDED',
productId: 'SKU-1234',
productName: 'Black Running Shoes',
value: 79.99,
currency: 'USD',
quantity: 1
})
sendCheckoutEvent(data)
Report when the user completes an order.
Data properties
orderId (string, optional) — Your internal order ID. The same ID won't be recorded twice.
value (number, required) — Total order value after discounts/taxes
currency (string, required) — ISO 4217 currency code (e.g.
"EUR"
)lineItems (array of objects, optional) — Details for each purchased item. Each item must include:
productId (string, required)
productName (string, required)
quantity (number, required)
value (number, required) — Total for that line (price × quantity)
currency (string, required)
Example:
window.gleenWidget.sendCheckoutEvent({
orderId: 'ORDER-7890',
value: 199.97,
currency: 'USD',
lineItems: [
{
productId: 'SKU-1234',
productName: 'Black Running Shoes',
quantity: 1,
value: 79.99,
currency: 'USD'
},
{
productId: 'SKU-5678',
productName: 'Running Socks (2-pack)',
quantity: 2,
value: 59.99,
currency: 'USD'
}
]
})
What happens behind the scenes
Company key is automatically included, so you don’t need to pass it.
Visitor fingerprints (
user_fingerprint
anduser_faq_fingerprint
) are added to tie events back to unique users.Events will only be recorded for visitors who have interacted with the chat widget or the Product FAQs feature in their session—ensuring that only revenue driven by those interactions is attributed.
Client‑side validation ensures all required fields are present and correctly typed.
Troubleshooting
Methods undefined Make sure the widget snippet has fully loaded and that you call these methods only after
window.gleenWidget
exists.No events appearing in your dashboard
Verify the user session included interaction with the chat widget or FAQs before the cart/checkout action.
Open Analytics > Revenue impact in the Alhena dashboard to view attributed add‑to‑cart and purchase revenue.
Validation errors Check the browser console for messages about missing or invalid fields and ensure you’re passing correct data types.
Last updated