'
analytics.subscribe('checkout_completed', (event) => {
// Example for accessing event data
const checkout = event.data.checkout;
const checkoutTotalPrice = checkout.totalPrice.amount;
const allDiscountCodes = checkout.discountApplications.map((discount) => {
if (discount.type === 'DISCOUNT_CODE') {
return discount.title;
}
});
const firstItem = checkout.lineItems[0];
const firstItemDiscountedValue = firstItem.discountAllocations[0]?.amount;
const customItemPayload = {
quantity: firstItem.quantity,
title: firstItem.title,
discount: firstItemDiscountedValue,
};
const paymentTransactions = event.data.checkout.transactions.map((transaction) => {
return {
paymentGateway: transaction.gateway,
amount: transaction.amount,
};
});
// Modify the payload to match the UET tag format
const payload = {
event: 'purchase',
ecomm_prodid: firstItem.variant.id,
ecomm_pagetype: 'purchase',
ecomm_totalvalue: checkoutTotalPrice,
};
// Send the payload to the UET tag
window.uetq = window.uetq || [];
window.uetq.push(payload);
});
});})(self.webPixelsManager.createShopifyExtend('82379029', 'custom'));