Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PiotrKrzyzek/e7c958db2152e01372d58bb90896dc7b to your computer and use it in GitHub Desktop.
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)
{% 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