I am facing a big issue with google analytics, its not showing up orders with correct date. A user on website placed order on 20-July-2018 but its showing up under 22-July-2018. As I checked my code 2-3 times and its having proper conditions to submit the reports only once for a order but really don't know whats wrong with API implementations. Can anyone have idea about this ?
Javascript Code :-
<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','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-1179*****', 'auto');
ga('send', 'pageview');
</script>
PHP Code :-
/* applied check to call this only once for a order */
echo "<script> ga('require', 'ecommerce');";
echo "ga('ecommerce:addTransaction', {
'id': '{$trans['id']}',
'affiliation': '{$trans['affiliation']}',
'revenue': '{$trans['revenue']}',
'shipping': '{$trans['shipping']}',
'tax': '{$trans['tax']}'
});";
//echo $this->getTransactionJs($trans);
foreach ($items as &$item) {
echo "ga('ecommerce:addItem', {
'id': '{$trans['id']}',
'name': '{$item['name']}',
'sku': '{$item['sku']}',
'category': '{$item['category']}',
'price': '{$item['price']}',
'quantity': '{$item['quantity']}'
});";
}
echo "ga('ecommerce:send');</script>";