Last active
August 29, 2015 14:04
-
-
Save bani/4e3fd2d4b462a8499c89 to your computer and use it in GitHub Desktop.
Code to be added to Checkout under "Additional content & scripts" in order to send transaction data to Google Analytics using Enhanced Ecommerce (Universal)
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"> | |
{% for line_item in order.line_items %} | |
ga('ec:addProduct', { | |
'id': '{{line_item.id}}', | |
'name': '{{line_item.product.title}}', | |
'category': '{{line_item.product.type}}', | |
'brand': '{{line_item.vendor}}', | |
'variant': '{{line_item.variant.option1}} {{line_item.variant.option2}} {{line_item.variant.option3}}', | |
'price': '{{line_item.price | money_without_currency}}', | |
'quantity': {{line_item.quantity}} | |
}); | |
{% endfor %} | |
ga('ec:setAction', 'purchase', { | |
'id': '{{order.order_number}}', | |
'revenue': '{{order.total_price | money_without_currency}}', | |
'tax': '{{order.tax_price | money_without_currency}}', | |
'shipping': '{{order.shipping_price | money_without_currency}}', | |
'coupon': '{% for discount in order.discounts %}{{discount.code}}{% endfor %}' | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment