- This topic is empty.
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Google Universal eCommerce Tracking
Am I doing this right? I’m just using an example with data already in it.
Not sure if this is the correct way to do this, as none of my test orders have landed into the Transactions area of Google Analytics.
<script>
(function(i,s,o,g,r,a,m){i[‘GoogleAnalyticsObject’]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,’script’,’//www.google-analytics.com/analytics.js’,’ga’);ga(‘create’, ‘UA–1’, ‘amleo.com’);ga(‘send’, ‘pageview’);
//Include the ecommerce plugin
ga(‘require’, ‘ecommerce’, ‘ecommerce.js’);
//Initialize the transaction
ga(‘ecommerce:addTransaction’, {
‘id’: ‘WEBA001399736’,// order ID – required
‘affiliation’: ‘A.M. Leonard’,// affiliation or store name
‘revenue’: ‘19.99’,// total – required
‘shipping’: ‘9.99’,// shipping
‘tax’: ‘2.10’,// tax
});
ga(‘ecommerce:addItem’, {
‘id’: ‘WEBA001399736’,// order ID – necessary to associate item with transaction
‘name’: ‘Leonard+ArborRain+Tower+-+Plant+%26+Tree+Hydrator’,// product name
‘sku’: ‘ART20’,// SKU/code – required
‘category’: ”,// category or variation
‘price’: ‘19.99’,// unit price – required
‘quantity’: ‘1’// quantity – required
});
ga(‘ecommerce:send’);//submits transaction to the analytics servers
</script>