Created
September 8, 2021 14:47
-
-
Save jorgejaramillo/44ccfd633271320a4f24a4a40431c53e to your computer and use it in GitHub Desktop.
Shopify dataLayer (Checkout - Purchase)
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
{% if first_time_accessed %} | |
<script> | |
window.dataLayer = window.dataLayer || []; | |
var shipping_price = '{{shipping_price | money_without_currency }}'; | |
shipping_price = shipping_price.replace(",", "."); | |
var total_price = '{{total_price | money_without_currency }}'; | |
total_price = total_price.replace(",", "."); | |
var tax_price = '{{tax_price | money_without_currency }}'; | |
tax_price = tax_price.replace(",", "."); | |
window.dataLayer.push({ | |
'page_type': 'purchase', | |
'event': 'analyzify_purchase', | |
'currency': "{{ shop.currency }}", | |
'totalValue': total_price, | |
'shipping': shipping_price, | |
'tax': tax_price, | |
'payment_type': '{{order.transactions[0].gateway}}', | |
'transaction_id': "{{order.name}}", | |
}); | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment