Sales tracking

Sales can be tracked by Pickzen once configured. Pickzen will differentiate between direct sales and indirect sales:

  • Direct sales: Sales of products that have been recommended by Pickzen.

  • Indirect sales: Sales of products not recommended by Pickzen. This is important in Assistants that don't recommend products, for example, a Sizer. Pickzen will claim an indirect sale only if the customer previously completed an Assistant.

The Sales module is disabled by default and it is only eligible for certain accounts. Write to us to evaluate your case.

Shopify

In order to track sales from products purchased in Shopify, log into your Shopify store and go to Settings / Checkout / Order processing / Additional scripts and add the following code:

{% if first_time_accessed %}<script>var pzOrderId={{order.order_number}};if(pzOrder={{checkout.order.line_items|json}} || {{order.line_items|json}},pzOrder){for(var pzProducts=[],pzI=0;pzI<pzOrder.length;pzI++){var line=pzOrder[pzI],gId=(line.product_id||line.product.id).toString();pzProducts.push({id:line.variant_id.toString(),gId:gId,price:parseFloat(line.price),quantity:line.quantity})}var pzTimer=setInterval(function(){window.pzIntegrationLoaded&&(clearInterval(pzTimer),window.pzConvertionTracker.notify(pzProducts,{order:pzOrderId}))},1e3)}</script>{% endif %}

Example:

Shopify + Recharge v1

In order to track subscription sales from Recharge v1, first ensure you followed the configuration steps for Shopify. Once done, open the Recharge app in your Shopify store, and click on Checkout:

Then, add the following code to the Thank you page, replacing first the XXXXXXXX code with your userId:

<script async src="https://admin.pickzen.com/client/id/XXXXXXXX"></script>

{% if first_time_load %}<script>function parseHtmlEntities(r){return r.replace(/&#([0-9]{1,3});/gi,function(r,t){var e=parseInt(t,10);return String.fromCharCode(e)})}var pzOrderId={{order_number}},pz_products=[];{% for item in line_items %}pz_products.push({id:"{{item.variant_id}}",gId:"{{item.product_id}}",price:{{item.price}},quantity:{{item.quantity}}});{% endfor %}var pzTimer=setInterval(function(){var r;window.pzIntegrationLoaded&&(clearInterval(pzTimer),(r=parseHtmlEntities("{{attributes.pzRechargeData}}"))&&(r=JSON.parse(r)).forEach(function(r){pzConvertionTracker.notify(pz_products,{order:pzOrderId},2,JSON.stringify(r))}))},1e3);</script>{% endif %}

Example:

You can get your userId in Integrations / Your Website / Pickzen Code

Finally, you need to add this code into Integrations / Your Website / Developers / Integration code:

window.pickzen.onCompletion = function(code, products) {
  jQuery.getJSON('/cart.js', function(cart) {
    var rd;

    if (cart.attributes.pzRechargeData) {
      rd = JSON.parse(cart.attributes.pzRechargeData);
    } else {
      rd = [];
    }

    var data = window.pickzen.utils.getByKey(rd, 'code', code);
    if (!data) {
      data = {
        code: code,
        ct: code + ',0:0',
        pt: []
      };
      rd.push(data);
    }

    products.forEach(function(p) {
      if (!window.pickzen.utils.getByKey(data.pt, 'id', p.id)) {
        data.pt.push(p);
      }
    });

    jQuery.post('/cart/update.js', "attributes[pzRechargeData]=" + JSON.stringify(rd));
  });
};

Shopify + Recharge v2

In order to track subscription sales from Recharge v2, simply ensure you followed the configuration steps for Shopify.

Other platforms

Go to Integrations / Your site and enter the fragment of the page that corresponds with your confirmation URL:

Below, in the Code to get purchased products, you can enter your custom JavaScript code to fetch the purchased products and send them to Pickzen:

var pzOrderId = orderId;
var pzProducts = products; 

var pzTimer = setInterval(function() {
    if (window.pzIntegrationLoaded) {
        clearInterval(pzTimer);
        window.pzConvertionTracker.notify(pzProducts, {
            order: pzOrderId
        });
    }
}, 1000);

Last updated