Skip to content

Instantly share code, notes, and snippets.

@tvpmb
Created October 8, 2019 23:34
Show Gist options
  • Save tvpmb/6ecdbddb29bdb57248fd924bd9ff5449 to your computer and use it in GitHub Desktop.
Save tvpmb/6ecdbddb29bdb57248fd924bd9ff5449 to your computer and use it in GitHub Desktop.
if (Shopify.hasOwnProperty('checkout')) {
var purchases = Shopify.checkout.line_items;
var orderId = Shopify.checkout.order_id;
var items = [];
for (var x = 0; x < purchases.length; x++) {
items.push({
sku: purchases[x]['sku'],
price: purchases[x]['price'],
quantity: String(purchases[x]['quantity'])
});
}
(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';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(tvpa, s);
})();
var _tvpa = _tvpa || [];
_tvpa.push(['config', {
li: '1759289',
firstPartyCookieDomain: 'tvpage-dev.myshopify.com'
}]);
_tvpa.push(['track', 'products', {
'tid': orderId,
'orders': items
}
]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment