Skip to content

Instantly share code, notes, and snippets.

@tvpmb
Created June 18, 2024 15:35
Show Gist options
  • Save tvpmb/357bb3f97e636902689cafea254ccd73 to your computer and use it in GitHub Desktop.
Save tvpmb/357bb3f97e636902689cafea254ccd73 to your computer and use it in GitHub Desktop.
Shopify Conversion Pixel Script
<script type="text/javascript">
(function() {
var tvpa = document.createElement('script');
tvpa.type = 'text/javascript';
tvpa.async = true;
tvpa.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'a.tvpage.com/tvpa.min.js';
let s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(tvpa, s);
})();
var _tvpa = _tvpa || [];
_tvpa.push(['config', {
li: "*** REPLACE ACCOUNT ID ***" // Account ID
}]);
var shopifyOrderData = {
"tid": "{{ checkout.order.id }}",
"orders": [
{% for line_item in checkout.order.line_items %}
{
"sku": "{{ line_item.product_id }}",
"price": "{{ line_item.final_price | money_without_currency }}",
"quantity": "{{ line_item.quantity }}"
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]
};
_tvpa.push(['track', 'products', shopifyOrderData]);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment