Last active
January 22, 2025 21:52
-
-
Save tvpmb/9df179d31b52947c107dba48fa4f0954 to your computer and use it in GitHub Desktop.
Creatable Shopify Pixel - Pure JS
This file contains hidden or 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
<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