- In Settings, navigate to Customer Events.
- Click Add Custom Pixel.
- In the code section, paste the following code:
analytics.subscribe('checkout_completed', (event) => {
window._rsq = window._rsq || [];
const checkout = event.data.checkout;
window._rsq.push(['_setSiteId', 'site_id']); // replace site_id with your static Site ID
window._rsq.push(['_enableOnsite']);
if (checkout.order.customer) {
window._rsq.push(['_setUserId', checkout.order.customer.id]);
window._rsq.push(['_setUserEmail', checkout.email]);
}
window._rsq.push(['_addOrder', { 'id': checkout.order.id, 'total': checkout.totalPrice.amount }]);
checkout.lineItems.forEach(item => {
window._rsq.push(['_addItem', {
'id': item.variant.id,
'name': item.title,
'price': item.variant.price.amount
}]);
});
window._rsq.push(['_setAction', 'checkout_success']);
window._rsq.push(['_track']);
(function() {
var rScix = document.createElement('script');
rScix.type = 'text/javascript';
rScix.async = true;
rScix.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'd1stxfv94hrhia.cloudfront.net/waves/v2/w.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(rScix);
})();
});
Comments
0 comments
Please sign in to leave a comment.