I have a Shopify shop and use Bold Commerce app for the checkout.
During months, I was able to use the following code in Bold Commerce to trigger the ‘Started Checkout’ event in Klaviyo.
It suddenly stopped working in July. Since then, I’ve contacted Bold Commerce support and they investigated during weeks : there is no issue on their end.
If I test it myself, Klaviyo will tell me that I’m “active on the website” when I start checkout.
So it does triggers something but not this specific event.
Is this code wrong? How can I fix it?
<script async type="text/javascript" src="//static.klaviyo.com/onsite/js/klaviyo.js?company_id=??????"></script>
<script>
var _learnq = _learnq || =];
const items = o];
const itemNames = ];
_learnq.push(_'identify', {
'$email': BOLD.order.customer.email
}]);
window.BOLD.order.line_items.forEach(function (item) {
itemNames.push(item.product_title);
items.push({
"SKU": item.sku,
"ProductName": item.product_title,
"Quantity": item.quantity,
"ItemPrice": item.price,
"RowTotal": item.total_price,
});
});
let klaviyoPayload = {
"$event_id": BOLD.order.public_order_id,
"$value": (BOLD.order.total / Math.pow(10, 2)).toFixed(2),
"ItemNames": itemNames,
"ResumeUrl": BOLD.order.resumable_url,
"Items": items
};
_learnq.push(_'track', 'Started Checkout', klaviyoPayload]);
</script>