Last active
May 31, 2018 02:51
-
-
Save PiotrKrzyzek/e7c958db2152e01372d58bb90896dc7b to your computer and use it in GitHub Desktop.
Shopify: Track purchased with FB Pixel & Google Analytics (run one time, detailed data)
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> | |
fbq('track', 'Purchase', { | |
contents: [ | |
{% for line_item in line_items %} | |
{ | |
'id': '{{ line_item.sku }}', | |
'quantity': {{ line_item.quantity }}, | |
'item_price': {{ line_item.line_price | money_without_currency }} | |
}, | |
{% endfor %} | |
], | |
content_type: 'product', | |
value: {{ total_price | money_without_currency }}, | |
currency: '{{ shop.currency }}' | |
}); | |
ga('ec:setAction', 'purchase', { | |
'id': '{{ order_number }}', | |
'affiliation': 'Store Name - Source', | |
'revenue': '{{ total_price | money_without_currency }}', | |
'tax': '{{ tax_line.price | money_without_currency }}', | |
'shipping': '{{ shipping_method.price | money_without_currency }}', | |
}); | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment