I'm building a custom webshop on Laravel and i started on an e-commerce tracking plugin. According to me, it should work, but it doesn't. Could someone tell me what i am doing wrong?
Here's my code on the thankyou page:
in the head section:
<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-1443260-52', 'auto');
ga('send', 'pageview');
</script>
And further down the page:
<script>
ga('require', 'ecommerce');
ga('ecommerce:addTransaction', {
'id': '133', // Transaction ID. Required.
'affiliation': 'Demo store 1', // Affiliation or store name.
'revenue': '40.00', // Grand Total.
'shipping': '15.00', // Shipping.
'tax': '4.34' // Tax.
});
ga('ecommerce:addItem', {
'id' : '133', // Transaction ID. Required.
'name' : 'Test product', // Product name. Required.
'sku' : '12', // SKU/code.
'category' : 'Kleur - Rood | Maat - 28inch', // Category or variation.
'price' : '25.00',// Unit price.
'quantity' : '1', // Quantity.
'currency' : 'EUR'
});
ga('ecommerce:send');
</script>
I have enabled e-commerce tracking in Analytics, and pageviews are registered
Your call looks fine to me. There are a few things you should be aware of.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.