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')


 


varch_orderId = window.chData.order.carthook_order_id;

varch_lastChargedLineItems = window.chData.order.last_charged_line_items;

varch_transactionProducts = [];

varch_taxPrice = 0;

varch_subtotalPrice = 0;

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

varch_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;

}

ch_subtotalPrice += (ch_item.price * ch_item.quantity);

}

varch_shippingRates = window.chData.order.last_charged_shipping_rates;

varch_shippingTotal = 0;

//Sum up shipping

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

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

}

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

juapp(

'order',

ch_orderId,

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

);

}

if (ch_transactionProducts.length > 0) {

for (vari = 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}

);

}

}

} catch(er){

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

}

</script>