OpenCart, Joomla, MijoShop and Piwik Analytics

I’m not exactly what you would call an ardent blogger – the sparsity of my posts on this site is testimony to that!  Mostly I’m simply too busy.  However, from time to time something comes along that I feel compelled to write about.  My recent experience with an ecommerce design project is an excellent example…..


I have used OpenCart as a shopping cart solution since its very early days back in 2007.  It was the brainchild of a British developer and there was but a handful of active contributors on the OpenCart forum, who were only too eager to lend each other mutual support and share hacks and improvements.  Paying for an extension was almost unheard of!  Nowadays, if you want anything over and above the out of the box functionality you need to prepare to shell out a few (or on some cases a lot of) dollars.  Largely I don’t have a problem with this – everybody has to earn a living and coding extensions takes time & skill.  What does tend to happen is, that when a project grows a large user base and becomes successful, the community practices of sharing and giving back for free have a tendency to diminish in favour of commercialism.

I was therefore very pleasantly surprised to come across an extension contribution that very much embodied the original spirit of the OpenCart community.  Please read on …….

Joomla and Ecommerce

For most of my clients a standalone ecommerce store solution is not enough on its own.  They also require features that are often only available in a robust CMS such as Joomla.  At one time the de facto ecommerce solution under Joomla was Virtuemart.  It was, however, a bit of a dogs dinner in terms of user friendliness and would frighten most of my clients to death to try to manage their products and sales with it.  Consequently my solution for this was to design matching templates for Joomla and OpenCart and to ‘integrate’ them, in look at least, from separate installations.  See the Bates Environmental site (using earlier versions of Joomla / OpenCart) as an example.

Recently several integrations of OpenCart into Joomla have appeared.  Some have been very basic, running OC in an iframe within a Joomla site and simply not worth wasting time over.  More recently fully integrated solutions have come to the fore.  One such solution is MijoShop (the developers split from Aceshop to take things in their own direction and formed MijoSoft, providing a number of Joomla-centric extenstions).  I decided to give this a try for my latest ecommerce project, having just had a dabble with Hikashop and determined it was only really OK for a store with a very small number of products.  So far I have been very pleased.  It really does combine all the advantages of Joomla with the ease of use and extendibility of OpenCart.  The support is pretty hot too, with the developers dealing swiftly and professionally with any issues that need to be raised via a support ticket.

The EU Cookie Law Thorn

Please bear with me – I’m not going off topic, honestly!  If you live within the European Union you’ll know exactly what this is.  If not please take a look here for a brief guide.  Personally I think one of the main reasons that this law came about was an unease about the quantity and use of information that Google harvests via the almost ubiquitous use of Google Analytics tracking by webmasters.  Such tracking uses cookies.  So, to ease the burden of compliance with the law, I set about finding an alternative means of tracking website visitors that doesn’t use cookies and came across Piwik, a truly opensource solution.  Piwik has an APi that allows the use of PHP to do the tracking and doesn’t set cookies.

Piwik is easy to install, can track data from any number of websites and tracks ecommerce transactions, including abandoned carts, very well.  It has excellent, fully configurable reporting.  Reports can be viewed live on screen, exported in various formats and scheduled to be delivered by email on a regular basis – clients love that!

Piwik and Joomla

Integration with a Joomla website is simplified by using this free plugin. The plugin uses the APi for PHP operation & hence no cookies. After installation just configure the url to your Piwik installation and the Site ID + Authentication Token assigned by Piwik and you’ll be good to go. So far so good …..

Piwik & MijoShop

This is where it starts to get tricky.  Although MijoShop integrates OpenCart very well within Joomla, Piwik doesn’t know that some of the Joomla pages it is tracking are ecommerce related.  Piwik therefore needs a plugin / extension specific to the shopping cart being used – in this case OpenCart …… enter Kevin Bibby …..

OpenCart Piwik Module

Kevin Bibby from Inane Coding is following in the true British spirit shown in the early days of OpenCart.  Kevin has released to the community an early free version of a module to integrate OpenCart installations with Piwik.  The module uses VQMod, so therefore doesn’t overwrite any pre-existing OpenCart files. I downloaded a free copy from GitHub and set about trying it out with my Mijoshop installation of OpenCart ……

Mijoshop, Joomla & Piwik

I followed the straightforward instructions and installed the module.  Configuration consisted of providing the url to the installation of Piwik, the full path to the PiwikTracker.php file on the server, The Piwik authorisation token (obtained from my Piwik Admin ‘API’ page) and the Site ID assigned by Piwik.  Time now to browse a few of the store’s pages, dump something in the cart and see if my activity was being tracked …… Oh dear – the dreaded white page of death as soon as I browsed to any page that was running MijoShop / OpenCart.

I examined the XML file that is used under VQMod for any clues as to the changes being performed on OpenCart.  I initially thought it was one specific piece of code and contacted Kevin via email.  A swift response was received with a suggestion to do some log checking.  Under MijoShop the usual OpenCart logs are redundant and it is necessary to look at the website’s error logs generate by Apache.  That quickly identified the cause … and the solution …

I hadn’t disabled the Joomla Piwik module so effectively 2 instances of tracking were being used and causing conflict.  The solution was pretty simple:

  1. Disable the Joomla Piwik module
  2. Use 2 templates on the site – 1 is set as default (used for MijoShop and therefore using the OpenCart Piwik module) and the second is assigned to any Joomla only pages on the site, i.e everything except the Mijoshop pages.
  3. Manually add the Piwik tracking code (unique for each site and provided within Piwik itself) to the index.php of the second template.

Now, the above was sufficient to start generating some ecommerce data, but it was only the stuff that was cart-related …. no tracking of pages on the store itself.  Further investigation showed that the injection of the Piwik Javascript into templatename->common->footer.tpl via the VQMod piwik.xml was somehow failing.

Answer: Use the Piwik tracking code as in 3) above within the Joomla template being used by OpenCart/MijoShop.  This will most likely mean you can use just the one template across the whole site with tracking code manually inserted (as opposed to using a Joomla plugin) + Kevin’s module.

Voila!  Superb data coming through now from all parts of the site.  As far as the OpenCart / MijoShop area is concerned, this is what Kevin’s module currently does:

  • Tracks regular page views
  • Tracks Ecommerce product views (category views not yet implemented)
  • Tracks Ecommerce cart add/update/delete
  • Tracks Ecommerce orders

Kevin is happy to accept donations toward his work on the project and I would commend anyone trying it out to chip a bit into the pot.  The combination of Joomla / OpenCart and Piwik has great potential to build and manage an ecommerce solution that really does allow you to make it work in the way you want and obtain hugely valuable information to create a positive visitor experience and obtain a high sales conversion rate.

Oh Dear – We’re back with Cookies

Those of you who have been paying attention will have realised that, to get all the above to work, requires use of the Piwik Javascript Tracking code (including its cookies) and the PHP APIs are no longer being used.  So, as yet, I haven’t managed to find an analytics solution that goes some way to beating the EU Cookie Law.  I’m sure it would be possible to do what is desired with Joomla, OpenCart/MijoShop & Piwik using the PHP APis but it is currently beyond my coding skillset.  Any takers out there?

PS – the store I have been building should launch by the end of August.  I’ll post details here for anyone that may be interested.  I’ll also tell you how you can opt out of being tracked by Piwik if you wish!

Leave a Reply

people follow