Skip to content

Instantly share code, notes, and snippets.

@karthik20522
Created May 25, 2019 07:19
Show Gist options
  • Save karthik20522/aed18b2f90feea4c36f4b878ad49d355 to your computer and use it in GitHub Desktop.
Save karthik20522/aed18b2f90feea4c36f4b878ad49d355 to your computer and use it in GitHub Desktop.
Shopify conversion tracking
<script type="text/javascript">
var items = {{ order.line_items | json }};
var item;
var productsArray = [];
for(var i = 0; i < items.length; i++) {
item = {
'sku': items[ i ].variant.sku,
'price': items[ i ].price,
'size': items[ i ].variant.option2,
'quantity': items[ i ].quantity
}
productsArray.push( item );
}
var shpfy_track = {
products: productsArray,
transaction : '{{ order.order_number }}',
amount: {{ order.total_price | money_without_currency }},
currency: '{{ shop.currency }}'
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment