Skip to main content

How to measure Heureka conversions

Updated over a month ago

Video: How to create Custom pixel

Tutorial: How to Create Custom Pixel

  1. From your Shopify admin, go to Settings > Customer events.

  2. Click βŠ• Add custom pixel.

  3. Give your pixel a unique name (e.g. Heureka) and click Add pixel

  4. 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']);
    }
    })
    });
    1. Optional: In the Customer privacy section, select the Permission and Data sale settings that you want to adjust.

  5. Click Save. If you're ready to connect your custom pixel, click Connect to start tracking your events.

Did this answer your question?