Skip to content

Instantly share code, notes, and snippets.

@martinsoender
Created November 24, 2021 17:22
Show Gist options
  • Save martinsoender/6b75b3f2d9d921b055447de9299c308d to your computer and use it in GitHub Desktop.
Save martinsoender/6b75b3f2d9d921b055447de9299c308d to your computer and use it in GitHub Desktop.
Vertebrae transaction script
<script>
window.$AXIS=window.$AXIS||function(){($AXIS.q=$AXIS.q||[]).push(arguments)};$AXIS.l=+new Date;
$AXIS('init', {
'clientId':'cca08230-da90-11eb-a86e-02766dea5d8a',
'environment':'prod'
});
// The addTransaction
$AXIS('ecommerce:addTransaction', {
'id': '{{ transaction.id }}', // Transaction ID.
'affiliation': 'Christopher Cloos',
'revenue': '{{ transaction.amount }}', // Grand Total. In float form 100.00
'shipping': '{{ transaction.shipping.price }}', // Shipping.
'tax': '{{ transaction.tax }}' // Tax.
});
// addItem
{% for ordered_item in checkout.ordered_items %}
$AXIS('ecommerce:addItem', {
'id': '{{ ordered_item.id }}', // Transaction ID - same as above.
'name': '{{ ordered_item.name }}', // Readable product name
'sku': '{{ ordered_item.sku }}', // SKU
'category': '{{ ordered_item.category }}', // Category
'price': '{{ ordered_item.price }}', // Item Price (for one)
'quantity': '{{ ordered_item.quantity }}' // Item Quantity
});
{% endfor %}
// Send the event
$AXIS('ecommerce:send');
var s = document.createElement('script');
s.async = true;
s.src = 'https://z.vertebrae-axis.com/scripts/transaction.js';
document.head.appendChild(s);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment