Knowledge Base      


How do I track Shopify Sales using post-purchase apps like Zipify?


In this article, we’re going to show you how to track your Shopify Sales when using a Post-purchase app like Zipify and many others.

Before you get started, you’ll want to make sure you have followed the steps outlined in the article below:

How do I add tracking pixels or JavaScript code to Shopify?

Inside of Shopify, you’ll start by clicking on “Settings” and then “Checkout” and where you see “Additional Scripts” you’ll see the Post-purchase section like shown below:

 

  
In this new Post-purchase page section, you’ll want to add your sales code:
  
<script>
   var clickmagick_cmc = {
     uid: '[USERID]',
     hid: '[HID]',
     cmc_goal: 's',
     cmc_amt: window.Shopify.order.totalPrice,
     cmc_ref: window.Shopify.order.number,
   }
</script>
<script src='//cdn.clkmc.com/cmc.js'></script>
<script>
(function() {
   var order = window.Shopify.order;

   // set up additional conversion tracking
   Shopify.on('CheckoutAmended', function(newOrder, previousOrder) {

   // identify which items were recently added, if any
   var oldItems = previousOrder.lineItems.map(function(line) {
     return line.id;
   });

   var addedItems = newOrder.lineItems.filter(
     function(line) {
       return oldItems.indexOf(line.id) < 0;
     }
   );

   // no new items were added, so we skip conversion tracking
   if (addedItems.length === 0) {
      return;
   }

   addedItems.map(function(item) {
      console.log("item price = " + item.finalLinePrice, "item id = " + item.id);
      // clickmagick_cmc.log('s', ref, amount, project);
       clickmagick_cmc.log('s', Number(item.id).toString(), item.finalLinePrice);
   });
 });
})();
</script>


That’s it!

Once an item is purchased from your store ClickMagick will track the sale in Campaigns.

Article 776 Last updated: 05/28/2022 7:22:14 AM
https://www.clickmagick.com/kb/?article=776