• Piwik Ecommerce Extension for Magento

    by  • Last modified:April 4, 2016 • Piwik, Plugin • 44 Comments

    magento and piwik

    Please read an update on this plugin here.

    One thing lacking from the Magento store was a Free Piwik Extension that gave you the real power of Piwik Ecommerce in your install. I am proud to announce, that today marks a change. I have released a plugin that automatically inserts the Piwik Tracking code into Magento 1.7. It automatically sets up Ecommerce tracking that you expect: product & category views, cart updates, orders, along with all standard Piwik tracking. You can get it here now! As of version 1.0.6, you also have access to your Piwik data from within Magento via an iFrame!

    To help with the installation an any questions, below is how to set it up, but trust me it’s so easy, you can do this before you finish a beer. The first step is to make sure you have installed, Piwik on your host. Make sure you set it up with your Magento Website and enable Ecommerce Tracking in the settings:

    Ecommerce Tracking Setting Piwik

    Once your Piwik is working,visit Magento to get the Piwik Extension for Magento. Click install to get the connection key you will need to paste in your Magento Connection Manager.

    magento connection manager

    All done. Now just go back to your Magento dashboard menu, click on System >; Configuration. You will find “Piwik Analytics Control” on the left hand side. If hit a 404 page, or any issues make sure you clear your Magento cache.

    magento piwik config menu

    Make sure you enable the extension (but it does not take to you save config). Fill in the address to your Piwik install and the site id.

    magento piwik config

    Your Piwik Auth Token, can be found in your Piwik Install under the API tab. Please note if more than one user will access the data, it is best practice to create a generic Piwik account, which can be shared by all users. Use this API key instead of the SuperUser Api Token.

    Once you have everything in place, click save config, (you’ll find it in the top right corner) and go enjoy your beer. You are now tracking your visitors and customers with Piwik. You can access your Piwik data from within Magento from “Reports” tab:

    iframe-piwik tab

    Below is an example of the iframe in action:


    Remember to include the whole Piwik in an iframe, edit your config/config.ini.php in your Piwik Install and add the following line:


    I have also created the below video to help you get through the install.

    For those code geeks, source code is available on Google and Github. If you encounter an issue, leave a message below. So what are you waiting for already? Go download it here. Happy tracking!

    Does this work with earlier versions of Magento (i.e 1.6.x)?
    No, it does not, out of the box. This extension uses Magento’s 1.7 compliance with EU cookie tracking rules. To make it work with earlier versions, I have created the following mod. I have tested on my local dev and seems to work ,but you should try for yourself. Just unarchive the file and make sure you clear your cache. Please note, this disables the EU tracking function added in Magento 1.7 for Piwik, so you will have to make sure you comply with local laws. Updated to Extension Version 1.1.1

    I get a 404 page after I click Piwik Analytics Control?
    Make sure to clear the cache. Sometimes you have to log out and then login. It’s a Magento Cache bug beyond my control.

    Why I am not seeing any Ecommerce tracking? All my carts are abandoned!
    This plugin has been tested with Express, Standard and Pro versions of Paypal. The solution in 99.9% of cases is that you need to ensure you have the right settings in Paypal/Magento. Make sure Data Transfer is on, make sure you use the right IPN url for Magento. Ect. The only other reason the plugin would not work is customer does not click “Return to Store” after finishing their purchase.

    I get blank pages in my theme, what can I do?
    If you experience a blank page, try changing to in the layout file.

    Can I restrict access to Piwik Analytics Control?
    Yes, by using the simple role permissions in Magento backend, you can restrict access to the iframe or Piwik analytics control.

    I want you to rewrite or modify your plugin just for me ?
    I always appreciate user input, but to rewrite or modify this plugin is not easy to do without breaking compatibility for all other users. You need to also keep in mind this extension is free. I do not make money from this module in any way. I did it for free to share with the community of Piwik users. If a request makes sense for the community (i.e to enable new Piwik functionality) I will work on it for free. However, in order to completely rewrite or modify a plugin for custom tastes takes time. I do not have an interest in doing this kind of work at this time. You are free to modify the plugin as you see fit. It was released open source and the code is published on Github.

    Can you add “X” feature, it would be cool?
    I am not making any changes to the plugin at this time except bug fixes. I have frozen development due to time restriction and the fact Magento 2 is the future.

    Does this work on Magento 2?
    No. This requires a rewrite of the plugin and lots of testing. I need to find time to do it and unfortunately I don’t have time.


    About The Author: Adrian has over 12 years experience in Digital Marketing and Analytics. He currently works as a Marketing Manager at Vanilla Forums, a modern forum software platform that allows clients to connect and engage their communities and customers. Adrian has extensive experience with Google and Piwik Analytics. He lives and works in Montreal.

    • Hiro Protagonist

      Adrian, first of all thank you for your effort on this and for making this extension available to the OSS community. I have installed the latest version of the extension on Magento and everything seemedd to go ok but I don’t get any data back, neither on the “native” piwik page, nor on the embedded one in Magento Admin. Where can I look first ?

    • harryk

      Fisrt thanks for this extension.
      I’ve only one problem.

      I can’t see visitor detailes log.
      When I click on the link, i’ve only the message “Data Loading” but nothing happened and I stay on the first page.
      Have you got an idea??

      Thanks in advance

    • Does this work with earlier versions of Magento (i.e 1.6.x)?

      Your patch is incomplete. You must also comment out the endif; matching the if statement you’re commenting out. It works great otherwise! Thanks!

      • @facebook-544540886:disqus that for catching. I missed it on the last update.

    • alex

      I installed it and got the following error message Class ‘Mage_PiwikAnalytics_Helper_Data’ not found in /home/username/public_html/app/Mage.php on line 546
      please advise

      I am using magento version 1.7.02

    • Any plans to further develop this extension for compatibility with Magento Enterprise 1.12?

      • I know there are users who have deployed in Enterprise without issue. You can try for yourself in a test/dev environment. To make an enterprise version would require an enterprise license — to cover the cost of this I would have to charge for the plugin. It’s also something that does not make sense to me in terms of time as the current plugin seems to work in enterprise.

    • Caleb

      Plugin seems to be working just fine, however our system logs are filling up with this:

      Notice: Undefined offset: 0 in /var/www//app/code/community/Mage/PiwikAnalytics/Block/Piwik.php on line 148

      Seems to be one entry per page load, which makes magento’s system log grow very large, very quickly. Any Ideas? Latest Piwik, magento CE, and your mod.

      • Are you using Piwik Magento Plugin 1.11?

        • Caleb

          Yep. Magento, Piwik 1.11.1, Piwik Magento Plugin1.1.1 (per Magento Connect Manager).

          • Hmmm. It must be related to your category names. Not seeing an issue on this side. What site is it on? I’ll take a look.

      • Marcus

        Have you found the problem/solution for the Notice ?

        I’m seeing the same in the logs…

        Fully up-to-date Piwik installation + Extension
        Magento Enterprise 1.12

        • this issue is related to categories. if you have no categories, the variable will be undefined. As this is unusual for a magento site to have no categories, the best bet is to modify line 148 where you mark

          $category_id = “”;

          that should work. When I have a chance I will add a fix.

    • 1Agency

      Great extention but we have a huge problem since some weeks and i dont know if the bug lies in this extention or in piwik itself.
      everytime someone is placeing something in the cart, it will be shown in piwik as abadoned cart.

      • All carts are abandoned until they are completed purchases. One issue could be users not clicking the “back to site” in Paypal. This is how Magento will tell Piwik the order is complete. To reduce this issue I recommend you keep users on your site for payment.

    • Daniel

      Hi, thank you for your great extension.

      One question: Since a few days we do not get ecommerce-sales. I think it is because we changed to an https-url. Is this reasonable?

      Thanks a lot

      • I am not aware of any issue with HTTPS. I would do a fake order and use Firebug to troubleshoot.

        • Daniel

          Hi, after switching back to http tracking is working again. I think it is an HTTP/HTTPS difference issue…

          • There are many issues that can affect things in Magento. Maybe another plugin is causing a conflict. If you can provide an error message that would help. I use this on Https without issue and no other user has reported this issue. I need more details to help you troubleshoot if I cannot replicate behavior that causes issues.

    • Stefan

      Hey Thanks for the great extension.
      I have the problem that some orders dont get tracked I have the ecommerce activated but from the last 10 orders only 2 got tracked.
      Does it only track Paypal order and not other payment methods? Also shouldn’t it track the order as done once it shows the success page and not if some clicks shop further. I think most people wont click shop further but then leave the site after the order is a success.

      • It should track Paypal and any method on Magento (order, check, etc). None of the other external payment modules however. In terms of success page, I assume you mean the one on Paypal. They need to continue shopping button on the site or we have no way to confirm success. Final note, the plugin is open source and anyone can contribute to the code on GitHub ;)

    • AndrĂ© Luiz Bellafronte Kutians

      Hello! This extension is compatible with Magento CE 1.8.x anda Piwik 2.0.x?

      • There are people using it without issue. It should work, but as always, please test first.

    • Maarten

      Hi Adrian, I get some error after install (manual and connect).

      No problems on homepage, but when go to admin > System > Configuration it gives:

      Fatal error: Class ‘PiwikMage_PiwikAnalytics_Helper_Data’ not found in /home/****/public_html/app/Mage.php on line 546

      Delete cache, login –> logout.

      Do you have a idea?

      • Try to delete the current Piwik plugin, and install fresh. Also please make sure you are on the most recent version of Magento.

        • Maarten

          I already treid a several times. Use magento

    • Tobi

      Hi Adrian, after updating Piwik to verison “2.10.0” I only get a blank area in the magento backend. The Magento backend is still fine but no content is loaded in the iframe. Are you familiar with this issue?
      Thanks in advance

      • Hey Tobi,

        I’m having trouble upgrading to 2.10.0, but it seems I am not alone. Until I can figure that out I will not be able to troubleshoot.

        • Tobi

          I also had trouble during the updating process of PIWIK. Just save your config file and upload the update files manually and overwrite the old ones. Then add your config file and it should work.

          • Hey Tobi, did not work for me, and I suspect they changed many things that broke compatibility (based in numerous pots in their forum). I will not be able to troubleshoot at this time. The only thing I can suggest is to ensure you are using the most up to date version of the plugin. If this does not work you may have to downgrade your Piwik until we can collectivley figure it out.

    • Yehuda

      Hi, thanks for the extension!

      Just wanted to share that I’ve installed 1.1.6 and needed the pre Magento 1.7 mod. There was one incompatibility: I had to replace Mage_PiwikAnalytics_Helper_Data with PiwikMage_PiwikAnalytics_Helper_Data.


    • SENEE

      Hi, great extension !
      From the piwik iFrame in Magento I cannot edit nor delete a segment. I can also apply a new segment to other websites which is an issue for me using Piwik for differents websites.

      Do you know how I can fix it ?

      Thanks in advance

      • Are able to do it when you sign in directly to your install? Not sure it’s related to the plugin.

        • SENEE

          Yes directly from Piwik you can do it (only a super admin profile can do everything and create segment avaiblable for other websites). with your plugin, even if you change the authtoken (in piwik analytics Control) corresponding to consultation or administration profiles it’s still enable.
          The authToken isn’t used after the initial installation ?

          Thanks very much

          • The limitation is not from the plugin, but from Piwik. Please see here: http://forum.piwik.org/read.php?2,111627,111627. Iframe implementation is standard Piwik code, so it’s not related to my plugin, but how Piwik works.

            • SENEE

              I checked it. Thanks. From this iFrame you can create a segment but you can’t edit or delete it…

    • andreji.parnassius

      I had a problem with e-commerce sales not being tracked.
      Visitors etc. worked fine, but a completed sale was not showing up in Piwik.

      What I did to fix this in my Magento installation is changing the location where the JavaScript snippet is being placed.
      Copy layout/piwikanalytics.xml to your theme and replace


      Now the Piwik JS code on my site is before the actual footer, instead of before the closing tag.

      The footer.before block is standard and included in app/design/frontend/rwd/default/layout/page.xml