Video: How to create Custom pixel
Tutorial: How to Create Custom Pixel
From your Shopify admin, go to Settings > Customer events.
Click β Add custom pixel.
Give your pixel a unique name (e.g. Heureka) and click Add pixel
Paste your code generated from the Integration page into the Code window. Don't forget to change __PUBLIC_API__ to your key in the code.
var heurekaScript = document.createElement('script');
heurekaScript.src = 'https://im9.cz/js/ext/1-roi-async.js';
var firstScript = document.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(heurekaScript, firstScript);
const mapItem = (productVariant, quantity = 1) => {
const product = productVariant.product
return [
'addProduct',
product.untranslatedTitle,
productVariant.price.amount,
quantity,
productVariant.id
]
}
analytics.subscribe('checkout_completed', (event) => {
heurekaScript.addEventListener('load', () => {
const checkout = event.data.checkout;
var _hrq = window._hrq;
if(_hrq){
window._hrq.push(['setKey', '__PUBLIC_API__']);
window._hrq.push(['setOrderId', checkout.order.id.toString()]);
checkout.lineItems.map(lineItem => {
window._hrq.push(mapItem(lineItem.variant, lineItem.quantity));
})
_hrq.push(['trackOrder']);
}
})
});Optional: In the Customer privacy section, select the Permission and Data sale settings that you want to adjust.
Click Save. If you're ready to connect your custom pixel, click Connect to start tracking your events.