logo
logo
Sign in

Google Ecommerce Tracking Opencart 3.0

avatar
Purchase Theme
Google Ecommerce Tracking Opencart 3.0

Google Ecommerce Tracking is used to track the Ecommerce related information to your Google Analytics Account. Opencart by default comes with Google Analytics using which you can track:

  • Audiences
  • Acquistion
  • Behaviour etc

Basic Analytics Code ( Default with Opencart ):

<!– Global Site Tag (gtag.js) – Google Analytics –>

<script>

window.dataLayer = window.dataLayer || [];

function gtag(){dataLayer.push(arguments);}

gtag(‘js’, new Date());

gtag(‘config’, ‘UA-XXXXXXXX-X’);

</script>

Ecommerce Tracking Code ( It is not default with Openart ):

<!– Google Analytics Ecommerce Tracking Code –>

<script type=”text/javascript”>

var _gaq = _gaq || [];

_gaq.push([‘_setAccount’, ‘<?php echo $ga_account_num;?’]);

_gaq.push([‘_trackPageview’]);

_gaq.push([‘_addTrans’,

‘<?php echo $grand_total;”?>’, // total – required

‘<?php echo empty($shipping_total) ? 0 : $shipping_total;?>’, // shipping

‘<?php echo $city;?>’, // city

‘<?php echo $zone;?>’, // state or province

‘<?php echo $country;?>’, // country

]);

// add item might be called for every item in the shopping cart

// where your ecommerce engine loops through each item in the cart and

// prints out _addItem for each

<?php foreach($products as $product) { ?>

_gaq.push([‘_addItem’,

‘<?php echo $order_id;?>’, // transaction ID – required

‘<?php echo $product[“model”];?>’, // SKU/code – required

‘<?php echo $product[“name”];?>’, // product name

‘<?php echo $product[“price”];?>’, // unit price – required

]);

<?php } ?>

_gaq.push([‘_trackTrans’]); //submits transaction to the Analytics servers

(function() {

var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;

ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl&#8217; : ‘http://www&#8217;) + ‘.google-analytics.com/ga.js’;

var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);

})();

</script>

<!– Google Analytics Ecommerce Tracking Code –>

To make Google Ecommerce tracking to work you need to add both the codes which is only possible through the help of extension which is ready and well tested also during install your default file did not overwrite.

URL: https://www.purchasetheme.com/product/google-ecommerce-tracking-opencart/
Extension Cost: $35
Installation/Support: FREE ( Life Time )

collect
0
avatar
Purchase Theme
guide
Zupyak is the world’s largest content marketing community, with over 400 000 members and 3 million articles. Explore and get your content discovered.
Read more