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 –>


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

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

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

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


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;?’]);



‘<?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) { ?>


‘<?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😉 + ‘’;

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



<!– 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.

Extension Cost: $35
Installation/Support: FREE ( Life Time )

About the author

Purchase Theme

PurchaseTheme provides professionally designed mobile-friendly website templates, themes, facebook pixel code, magazine theme, Algolia Opencart etc.

View all posts

Leave a Reply