Skip to content

Instantly share code, notes, and snippets.

@tvpmb
Last active January 22, 2025 21:52
Show Gist options
  • Save tvpmb/9df179d31b52947c107dba48fa4f0954 to your computer and use it in GitHub Desktop.
Save tvpmb/9df179d31b52947c107dba48fa4f0954 to your computer and use it in GitHub Desktop.
Creatable Shopify Pixel - Pure JS
<script type="text/javascript">
let order = Shopify.checkout;
let tid = order.order_id === null ? null : order.order_id;
let products = order.line_items.map(item => ({
sku: item.product_id,
price: item.price,
quantity: item.quantity
}));
let orderData = {};
orderData.tid = tid;
orderData.orders = products;
(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
}]);
_tvpa.push(['track', 'products', orderData]);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment