Inane Coding Go on, slap that wayward code

Piwik OpenCart Ecommerce VQmod


How & Why?

It was late 2012, and I wanted to use Piwik to track Ecommerce transactions on my OpenCart store. There was a mod for nearly every other major shopping cart but not for OpenCart. Well, I thought, there damn well should be!!

And so, the InaneCoding Piwik OpenCart Ecommerce VQmod was born!

Piwik - - a highly successful open source web analytics platform. A serious alternative to google analytics and one which I swear by!

OpenCart - - A popular and powerful choice for open source shopping cart software, and my personal favourite.

VQmod - - A brilliant modding system for php or similar files, which allows the modifications to be specified in XML files without the original files ever needing to be changed. Essential for most opencart mods (including this one!), and for good reason.


 What does it do?

Why, it implements Piwik Ecommerce tracking for Opencart of course!

This is the most complete Opencart Piwik module currently available and is listed on the official Piwik website as the recommended module for use with Opencart. Plus its free :)

  • Tracks regular page views.
  • Tracks Ecommerce product views (category views not yet implemented).
  • Tracks Ecommerce cart add/update/delete.
  • Tracks Ecommerce orders.
  • Tracks searches on the opencart product search.
  • OpenCart admin backend for modifying settings.
  • Option to use Piwik Proxy Hide Url script to obfuscate the URL in the javascript code.
  • Fully VQmod'ed up! Does NOT overwrite any core files.

All this adds up to allow tracking of rich metrics for things such as page views, visitors, entry/exit points, keywords, ecommerce orders, products, sales leads, conversion rates etc.

You can find out more info in the readme.txt file which accompanies the mod.

To setup only takes a few minutes and 8 boxes to fill in, then you'll have full e-commerce tracking. Here is a screenshot of the admin page for the mod:

v2.0 admin interface


Where can I get it?

The latest version is v2.0 (2015-05-03) and is available from the Piwik OpenCart Ecommerce VQmod github page. Or, alternatively use the github direct download link if you're not familiar with how to navigate github.

The mod is also listed on the extension store.


What if I have questions?

Please read the included readme.txt file and you will likely be able to find your answer there. If not then please get in touch.



I DO do this in my spare time for the good of other people - I have released this mod for free in the spirit of the Open Source community, so anything you give to support me would be most appreciated and give me that little extra push to do more features and updates for you guys :)
Please donate if you use this mod and are able to give something.

Comments (58) Trackbacks (6)
  1. Looks great! I’ve been looking how to easily integrate piwik with opencart. (I almost converted to prestashop since it has a plugin for this already!) I’ll try this plugin. Thanks!

  2. It asks for “full secure url to Piwik installation” and it’s required field. Does it have to have one? Because I just installed on a regular folder.

  3. Hi Jay,
    I hope it helps you out, please let me know your feedback using once you’ve had a chance to test. Or contribute code or issues to the github page!

    As of v0.3 the Piwik urls are not structured as I’d ideally like them (bit of a mistake when I first coded it). “full secure url to Piwik installation” is the URL used for HTTPS (secure SSL) communications to your piwik installation. Enter the same as the non-secure Piwik URL but with ‘https://’ instead of ‘http://’ (even if you don’t use https on your site). In a future version I will remove this and work it out in the code instead but for now your need to enter it.


  4. Great plugin!!

    Only one thing in the vqmod xml you should use:
    file name=”catalog/view/theme/*/template/common/footer.tpl”
    file name=”catalog/view/theme/default/template/common/footer.tpl”

    Thanks again for this plugin.

  5. Hi Kevin,

    Just wanted to say a big thank you for developing this plugin! I’ll be installing it on my store ASAP – will let you know if any issues arise.


  6. I get error like this in my Error Log
    2013-08-16 19:24:14 – PHP Notice: Undefined index: HTTP_REFERER in /home/akmalseh/public_html/ on line 92
    2013-08-16 19:24:14 – PHP Notice: Undefined index: HTTP_ACCEPT_LANGUAGE in /home/akmalseh/public_html/ on line 96

    Need help.

  7. Hi,
    I followed your instructions on how to install piwik with joomla/mijoshop/opencart and the vQmod causes problems:
    the error log says search not found
    the frontside of the page just doesn’t load articles onto the cart, nor does it let you check out.
    Once I disable your vQmod, everything works like a charm again.

    Any ideas?
    Thank you for your work so far… I really wish it could work for me too.
    Please help,


  8. Hello Kevin,

    Thank you for your fast reply.

    It seems the errors were due to the modification you suggested.

    However, the checkout problem still persists: the user can add products to the cart but cannot complete the checkout process after inserting all the details.

    I can’t seem to be able to open the .rar files which the ‘vqmod cache dump’ generates, nor can i attach them to a message to send them to you.

    I appreciate your help,
    Thank you very much


  9. Hi,

    Do you have any plans for Piwik 2.0 compatibility?


    • I didn’t know it had been released, but I see it was only today so I’m not too late to the party :)

      Yes, in short. Although at the moment I have no idea what needs changing, if anything. I had a look at the piwik release notes for 2.0 and they didn’t mention anything specific changed about the core way the API or JS is called, but I could be wrong from a first glance. Have you tested yourself? Please use the contact page and send me some info if you have. If not I will test when I am able, though it will probably be after Xmas as I do this in my spare time – unless of course I get some detailed info from someone else who has tested :) *hint* *hint* !


      • Sorry, I was being a bit of a lazy arse and just assumed it wouldn’t work with Piwik 2.0 without actually testing it properly. Looks like this isn’t the case according to bmcrec’s comment. Thanks!

  10. Hello all, I have just successfully installed v0-4 release piwik opencart ecommerc vqmod on OpenCart Version 1.5.6 with vqmod version 2.4.1 and Piwik 2.0.1. I have full site tracking including Ecommerce. All with no customizations, no adjustments, no errors. Total plug and play, Awsome!!
    Thanks so much.

  11. I just installed on my webstore and everything seems to have install o.k., yet -this is a dumb question- but how do i know it all went o.k.? .. and is working? I am already tracking all i can on my piwik main install. Where will i see the results from this, it being an extension in my store admin? Just don’t see any usage directions at all. Thanks, Rick.

    • If you already have Piwik code on your site, you would be best to remove it completely before installing this mod as it inserts its own code.

      Once installed and working you should see the ecommerce orders and product views reports populated, and abandoned carts and orders show up with little icons in the visitor log. You should also see in the source code of the webpage a _paq.push(["setEcommerceView" ... term at the bottom with product info of the currently viewed product. I can’t check your site because its currently giving a HTTP 500 error.

      • It’s been down since i installed this module and did not know it. I had to uninstall it and still site was down, so i found the xml file and deleted it and my site is back up. Thank goodness.

        In admin on error page it was giving this report:

        2013-12-31 17:13:49 – PHP Warning: require_once() [function.require-once]: Filename cannot be empty in /hermes/bosweb26b/b649/ipg.rykeproductscom/catalog/model/tool/piwik.php on line 46

        Don’t know what all that means, but hate i lost a day of service on my webstore. I can’t believe it did not check it after loading this extension. It just loaded up fine it seems. Glad removing the xml file got me back up and going.

        I may just leave it alone. I seen they just released the 2.0 piwik and may just wait and get that set up for know. May try this later when i have the time and can remove the other install or move it to another folder on my server. I use it to monitor my other sites i sell on, ebay, bonanza, and 7 or 8 others. Thanks for the app will see about getting it going later.


        • Hi,

          That error means the filename you entered in the ‘Full path to the PiwikTracker.php file’ admin setting is wrong, and implies it is empty. Go back and check that.

          Having said that this is something that I’ve seen before and causes a lot of problems so I should do something to make it fail more elegantly – I’ve made an issue for it on github and I’ll try and fix this for the next release –


        • PS. You’ve got the Piwik image tracker code on your pages three times somehow! You may also like to consider using the javascript code instead of the image tracker as it has more complete tracking info.

          If you want me to help you get the mod up and running just send me an email through the contact page –

        • Thanks for all the help. I think i will hold what i have for now, me with all the other tracking i have with the main piwik program. I well check that out about having it listed more than once on main page and the product pages. The java script did not work for me for some reason. Don’t know why.

          It seems to be working fine though. I guess piwik 2.0 needs to be setup all by it’s self, because it says i’m up to date when i check for new updates. I want to try that release before i do anything else.

          Thanks, Rick.

  12. Hi, inanecoding! Can, please, help. Install module and when active tracking have on frontend – “Notice: Undefined index: route in ~/catalog/model/tool/piwik.php on line 218” in this line “if ($this->request->get[‘route’] == “product/search”)” – i dont undestand whats wrong?

    • Hi! Thanks for reporting, I’ve had another user report this aswell. Its because I’ve used that GET variable without checking if its set.

      For now to stop the notice displaying (will still work) you can change your OC admin setting to stop these notices displaying (you should change this back once I’ve made a fix);
      Admin->System->Settings->[edit your configured store]->Server->Display Errors

      I’ve created a bug at and will try and do a small fix soon.

      • Same error as noted above;

        Undefined index: route in catalog/model/tool/piwik.php on line 218

        New install and fresh setup.

        • Thanks, thats several people now this was a bit of an oversight obviously :) I’ll correct this for the next release. I’ll try and do this as a priority but may not be immediately as I do do this in my free time. Cheers for reporting.

  13. Piwik and opencart installed on diffrent Virtual Machine

  14. inanecoding, Thanks! Can you please help one more time:
    Whats change need do for install module if piwik installed on other PC (im use esxi – opencart and piwik on diffrent VM, and on the same LAN). Im trying Piwik installation URL: its right be?

    • ooo not completely sure. You need to enter the Piwik URL in the setting page, this shouldnt matter if its on a different server to the OpenCart store as long as its accessable.

      This is the URL which the visitor to the website would need to enter to go to the Piwik site. i.e. when you go to your Piwik admin panel what URL do you enter? Its probably that.

      If you’re doing a local install and thats the IP address of your machine Piwik is installed on then yes it may be correct, though can’t be sure without trying. Put it in the admin panel for the mod and see if it works!

      • I haven’t figured out how to make it work if OC and Piwik are 2 separate VPS with different IPs ect etc. Looking ad the documentation I understand this cannot be done. Can you please clarify.

        installation guide read as per below
        3. The default install assumes that Piwik is installed to the ‘/piwik/’ folder at the root of your OpenCart site.
        If you have used a custom install path then please place the ‘PiwikTracker.php’ file from ‘/upload/piwik/PiwikTracker.php’ to your custom Piwik folder.

        then in the editing page on OC you have field that takes only a full path.
        * Full path to the PiwikTracker.php file:
        Commonly this may be;
        (with ‘~user’ as your hosting username).
        May vary with server configuration.

        • The piwiktracker.php file should go on the OC server, and is needed so that the code can be included.

          This is then used when making accesses to the remote Piwik server where piwik is installed.

          So just enter the Piwik URL for the Piwik server correctly in the admin settings, as well as the PiwikTracker.php filepath on the OC server, and it should all work correctly.

  15. I have installed the plugin but get this message:”File unreadable – the path entered is not a valid readable file location.” I’m pretty sure the path is correct: /domains/ (checked in directadmin and ftp) and files/paths are readable. Any suggestion please?

    • As posted on extension store (no need to ask the question twice!);

      @Pinchecl: That error means the file is not readable! It uses the PHP ‘is_readable’ function. So, check and check again. If you really really cant get it to work I could check if the file locations entered make sense – contact me on

    • …that file path does look correct though. There’s probably some nuance to the folder structure – possibly it starts with ‘/home/’ or similar? Maybe the permissions aren’t set properly? There’s not much I can do though, you’ll have to figure out why its not accessible. Send a question to your server host perhaps?

      • Ok, thanks, I’ll keep trying to figure it out

        • Found the right absolute path by loading a pathinfo.php script. So that is solved. However, If I enable the Piwik Tracking my frontend doesn’t load, just gives an error “invalid or unsupported form of compression” while my errorlog, like some of the posts above, says “Undefined index: route in /home/koffert2/domains/ on line 218”.

        • Glad you solved the path error.

          I think after some googling that the ‘unsupported form of compression’ error is due to the error you see in your error log, due to the PHP Notice which gets generated being accidentally inserted into the compressed HTML output (which results in part of the output being compressed and part being uncompressed, which breaks the decompression algorithm). Its explained well here, look at the second comment down;

          My next release of the mod will fix these “undefined index” errors and hopefully this should then work aswell. I will try to get this some soon but have to fit around time for other things.


  16. Just to say a big thank you!
    Glad I came a reading helped me get this mod up and running.

  17. Kevin, thanks for all your work on this, it is a great module. We just sent you a donation for your efforts, keep up the great work!

    We also forked this on GitHub and modified it for MijoShop, which is a Joomla extension that ports OpenCart into the Joomla CMS. Hope it helps others, you can find it here:

  18. I fell for prestashop because it looks so good on the outside. Turns out that prestashop is heavily bloated and pages don’t load well in a browser. I am so glad I found OpenCart because it is a very fast webshop. I found many modules available for adding more functionality. Template system with direct php tags makes it totally open to design or code whatever you want. Perfect webshop for me.

  19. Further to a recent post, I provide the following Error Log information which I hope may be relevant in assisting me…

    ———- Date: 2015-03-03 00:02:32 ~ IP : ———-
    REQUEST URI : /admin/index.php?route=common/dashboard&token=0f80d140837a0e19a4b5d010424e2ae5
    modFile : /home4/opticey1/public_html/buymythings/vqmod/xml/piwik.xml
    id : InaneCoding Piwik OpenCart mod v0.4 (pre-release)
    version : 0.4
    vqmver : 2.1.6
    author : Kevin Bibby /
    VQModObject::parseMods – Could not resolve path for [catalog/controller/module/cart.php] (SKIPPED)

    ———- Date: 2015-03-03 00:41:18 ~ IP : ———-
    REQUEST URI : /index.php?route=product/category&path=25_27
    modFile : /home4/opticey1/public_html/buymythings/vqmod/xml/piwik.xml
    id : InaneCoding Piwik OpenCart mod v0.4 (pre-release)
    version : 0.4
    vqmver : 2.1.6
    author : Kevin Bibby /

    File Name : catalog/controller/common/footer.php(0)
    VQModObject::applyMod – SEARCH NOT FOUND (ABORTING MOD): $this->render(

  20. I just wanted to ask … is there a version for OpenCart available yet?

  21. Thank you for your hard work
    Changed wildcard to default in footer.tpl
    No errors
    But no Admin Control Panel ?
    Rootpath is ../opencart/admin
    Uninstalled and reinstalled but still no control panel …
    Checked the database and no token in settings and no new tables .. what is missing – any ideas?

    • Why have you changed the wildcard? There should be no need to alter the mod. You need to give more info… what opencart version? what version of my mod? What piwik version? Where did you upload the install files to? What settings have you entered in the admin? Have you checked both VQmod logs and opencart logs for errors? What do you mean by “no control panel” ?

  22. New install of Opencart, vqmod-2-5-1-5 and piwik 2.13.1 on there. Copied over your files, went to modifications and hit refresh, back to modules and there is no ‘Piwik OpenCart Ecommerce mod’… any suggestions?

  23. Nevermind, I don’t think I had vqmod installed correctly. It’s showing up now.

  24. it works with Cloud-hosted Piwik? ( )

    • I have no idea! I’ve got no experience of cloud-Piwik. However I haven’t had anyone say it doesn’t, and also I see no reason why it wouldn’t work – it should be the same Piwik product just hosted somewhere else. As long as its referenced properly in the admin of the mod it should work fine.

  25. Hi,
    this plugin is compatible with and
    or anyone tested this version?

    • I’ve not tested it yet. It depends on if there have been breaking changes in OC or Piwik. Someone who uses these may be kind enough to post…

    • Actually, someone posted late last year on the extension store “I use OC, vqmod 2.5.1 and piwik 2.14.3 and everything seems to be ok.” so it probably did with that version. Not sure if Piwik is later or earlier than 2.14.3 though! Are you sure version number 2.14.3 is correct??

  26. Hi, anyome test this plugin in opencart

  27. Hi. Can I use this code with OpenCart version?

    • I haven’t tested or updated it myself. I’ve been meaning to do this for a while but its not at the top of my priorities. Have a go though and let me know how you get on? Or better yet if you work out the code changes needed then contribute the code and I’ll do an update (do a pull request on github)

Leave a comment

CAPTCHA human-ness test: *