← Starting Page

← How to enable tracking and consent

<aside> 💡 Written by Marina Koch, last updated on 21st of October 2024

</aside>

<aside> 🎓

What you will learn in this article:

  1. Open Shopify.

  2. Go to SettingsCustomer Events.

  3. Click “Add custom pixel”.

  4. Name the Pixel “Admetrics Checkout Pixel”.

  5. Under Customer privacy:

    1. Set Permission to Required and select Analytics.
    2. Ensure Data Sale is set to “Data collected does not qualify as data sale”.

    custom pixel settings.png

  6. Paste the following code into the text box, and make sure to replace SHOP_ID_GOES_HERE with the correct shop ID. Retrieve your shop ID by clicking here, adjusting the domain to your shop, and searching for shopId.

    analytics.subscribe('all_events', (event) => {
        switch (event.name) {
            case 'checkout_started':
            case 'checkout_completed':
            case 'checkout_shipping_info_submitted':
            case 'checkout_contact_info_submitted':
            case 'checkout_address_info_submitted':
                (function (w, d, s) {
                    var SID = 'SHOP_ID_GOES_HERE';
    
                    if (event.name !== 'checkout_completed') {
                        w.admDataLayer = w.admDataLayer || [];
                        w.admDataLayer.push({ name: event.name });
                    }
    
                    var f=d.getElementsByTagName(s)[0],
                        l=d.createElement(s),j=d.createElement(s);
                    f=f.parentNode?f:d.getElementsByTagName("head")[0];
    
                    _r('js-app-admq-script');
                    j.id = 'js-app-admq-script';
                    j.async = true;
                    j.src = '<https://shopify.admetrics.events/conversion-v1.min.js>';
    
                    _r('js-app-admq-data');
                    var cod = (event.data && event.data.checkout &&
                               event.data.checkout.order)||{},
                        coi=cod.id||"",cci=cod.customer?cod.customer.id||"":"";
    
                    l.id = 'js-app-admq-data';
                    (l.type = 'application/json'),
                        (l.textContent = JSON.stringify({
                            sid: SID,
                            oid: coi,
                            cid: cci,
                        }));
                    _a(l) && _a(j);
    
                    function _r(e){
                      var n=d.getElementById(e);
                      return n&&n.parentNode.removeChild(n)}
                    function _a(e){
                      return f.parentNode?f.parentNode.insertBefore(e,f):
                        f.appendChild(e);}
                })(window, document, 'script');
                break;
            default:
                return;
        }
    });
    
  7. Click “Save” and then “Connect”.