Carthook Code

Here's the code you can use with Carthook

Introduction

After collaborating with Carthook, we updated the code to help ensure the initial click counts the conversion and only the initial click. At this time, it will not report on all upsells that happen after the initial submission. Please contact support@justuno if you have any questions.

 

Instructions

Add the following to CartHook's Global Scripts section - footer. You will need to update the code below with your embed code id - This is the number that follows "ju_num=" in the embed code page. 

<script>

try{

window.ju_num="Embed Code";window.asset_host='//cdn.justuno.com/';(function(i,s,o,g,r,a,m){i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)};a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script',asset_host+'vck.js','juapp');

 setTimeout(function(){

   var ch_orderId = window.chData.order.carthook_order_id;

   var ch_shopifyOrderId = window.chData.order.order_id;

   if (ch_orderId && ch_orderId!='') {

     var ch_lastChargedLineItems = window.chData.order.last_charged_line_items;

     var ch_totalPrice = window.chData.order.total_price;

     var ch_subtotalPrice = window.chData.order.subtotal_price;

     var ch_transactionProducts = [];

     var ch_taxPrice = 0;

     for (var i = 0; i < ch_lastChargedLineItems.length; i++) {

         var ch_item = ch_lastChargedLineItems[i];

         ch_transactionProducts.push({

           'sku': ch_item.sku,

           'name': ch_item.title,

           'price': ch_item.price,

           'quantity': ch_item.quantity,

         });

         if (ch_item.tax_amount) {

             ch_taxPrice += ch_item.tax_amount;

         }

     }

     var ch_shippingRates = window.chData.order.last_charged_shipping_rates;

     var ch_shippingTotal = 0;

     //Sum up shipping

     for (var i = 0; i < ch_shippingRates.length; i++) {

         ch_shippingTotal += parseFloat(ch_shippingRates[i].price);

     }

     juapp(

       'order',

       ch_orderId,

       {total:parseFloat(ch_totalPrice),subtotal:parseFloat(ch_subtotalPrice),tax:parseFloat(ch_taxPrice),shipping:parseFloat(ch_shippingTotal),currency:'USD'}

     );

     ju_conv_cart();

     if (ch_transactionProducts.length > 0) {

       for (var i = 0; i < ch_transactionProducts.length; i++) {

         juapp(

           'orderItem',

           {sku:ch_transactionProducts[i].sku,name:ch_transactionProducts[i].title,quantity:ch_transactionProducts[i].quantity,price:ch_transactionProducts[i].price}

         );

       }

     }

   }

 },1500)

} catch(er){

 console.log('could not run Justuno Script')

}

</script>