Last active
October 30, 2020 21:37
-
-
Save richardcalahan/8dad083cb072538bb4f89ab76e41df15 to your computer and use it in GitHub Desktop.
Lake and Skye - Narritiv Checkout Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var productsPurchased = []; | |
var orderTotal = 0; | |
{% for item in checkout.order.line_items %} | |
productsPurchased.push({ | |
product_id: '{{ item.variant_id }}', | |
product_name: '{{ item.title }}', | |
product_brand: '{{ item.vendor }}', | |
product_size: '{{ item.grams }}', | |
product_price: '{{ item.final_price }}', | |
product_quantity: {{ item.quantity }}, | |
}); | |
orderTotal += ({{ item.final_price }} * {{ item.quantity }}); | |
{% endfor %} | |
window.BAMX_EVENT_DATA = { | |
page_type: 'checkout', | |
is_new_visitor: {% if checkout.customer.has_account %}false{% else %}true{% endif %}, | |
products_purchased: productsPurchased, | |
order_id: '{{ checkout.order_id }}', | |
order_value: '{{ checkout.total_price }}', | |
currency: '{{ shop.currency }}', | |
}; | |
(function(account) { | |
try { | |
var b = document.createElement("script"); | |
b.type = "text/javascript"; | |
b.src = "https://static.narrativ.com/tags/" + account + ".js"; | |
b.async = true; | |
var a = document.getElementsByTagName("script")[0]; | |
a.parentNode.insertBefore(b, a); | |
} catch (e) {} | |
}("lakeskye")); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment