Skip to content

Instantly share code, notes, and snippets.

@marcfowler
Last active August 15, 2020 12:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcfowler/576b726b5c4e14fb9f9369e8a911b62f to your computer and use it in GitHub Desktop.
Save marcfowler/576b726b5c4e14fb9f9369e8a911b62f to your computer and use it in GitHub Desktop.
ThriveCart: Help: Google Analytics Ecommerce code
<script>
(function() {
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': _thrive_order.order.id,
'revenue': _thrive_order.order.total,
'tax': _thrive_order.order.tax,
'currency': _thrive_order.order.currency
});
ga('ecommerce:addItem', {
'id': _thrive_order.order.id,
'name': _thrive_order.order.bump.name,
'sku': _thrive_order.order.product.id,
'price': _thrive_order.order.bump.total,
'quantity': '1'
});
ga('ecommerce:send');
})();
</script>
<script>
(function() {
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': _thrive_order.order.id,
'revenue': _thrive_order.order.total,
'tax': _thrive_order.order.tax,
'currency': _thrive_order.order.currency
});
(function(downsell_id) {
ga('ecommerce:addItem', {
'id': _thrive_order.order.id,
'name': _thrive_order.order.downsells[downsell_id].name,
'sku': _thrive_order.order.downsells[downsell_id].id,
'price': _thrive_order.order.downsells[downsell_id].total,
'quantity': '1'
});
})(DOWNSELL_ID_HERE); // Replace with your downsell ID!
ga('ecommerce:send');
})();
</script>
<script>
(function() {
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': _thrive_order.order.id,
'revenue': _thrive_order.order.total,
'tax': _thrive_order.order.tax,
'currency': _thrive_order.order.currency
});
ga('ecommerce:addItem', {
'id': _thrive_order.order.id,
'name': _thrive_order.order.product.name,
'sku': _thrive_order.order.product.id,
'price': _thrive_order.order.product.total,
'quantity': '1'
});
ga('ecommerce:send');
})();
</script>
<script>
(function() {
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': _thrive_order.order.id,
'revenue': _thrive_order.order.total,
'tax': _thrive_order.order.tax,
'currency': _thrive_order.order.currency
});
(function(upsell_id) {
ga('ecommerce:addItem', {
'id': _thrive_order.order.id,
'name': _thrive_order.order.upsells[upsell_id].name,
'sku': _thrive_order.order.upsells[upsell_id].id,
'price': _thrive_order.order.upsells[upsell_id].total,
'quantity': '1'
});
})(UPSELL_ID_HERE); // Replace with your upsell ID!
ga('ecommerce:send');
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment