Piwik Analytics wordpress plugin

Note: latest version (0.7+) now requires Piwik 0.4 or higher! If you’re upgrading from 0.6: please reset some of your options, since the Piwik tracking code changed quite a bit.

Download it  from the wordpress.org plugin directory

This is a basic wordpress plugin for the excellent Piwik web Analytics tool. It adds the piwik javascript code into every page of your weblog, so you don’t have to code PHP to add it to your templates.

It is based quite heavily on the Google Analytics wordpress plugin by Joost de Valk.

The following options are supported:

  • hostname and path to Piwik options
  • site ID
  • option to control download tracking
  • option to exclude the admin user (probably you)

Your feedback is important. Please test it for me, report bugs, and leave feedback in the comments so I improve this software.

I will update this post whenever there is any news.

  • Updated to version 0.2.

    More config options (download tracking, extensions)
    Moved javascript code to footer
  • It seems to be working on my site.
    Thanks very much
    Mark
  • oops
    Your above download link, links to V0.1
    Mark
  • I am trying out piwik on my music project site and impressed by far. Hope this plug in can make me use piwik further. Thanks.
  • @Mark #6 Thanks for the heads up!


    And thanks for all compliments and links :-)
  • Version 0.3 is out! It features a minor cosmetic change to the admin interface.

    Also, you can get it now from the wordpress.org plugin directory!

    See http://wordpress.org/extend/plugins/piwik-analy...
  • elephant man
    Hi, for people that suck like me, the piwik plugin does't work... So, where do I put the Piwik code manually in Wordpress?
  • @elephant_man

    It depends on your theme. For my site http://loes.tv/ that uses the ‘techdesignscouk” theme, I altered the file *wp-content/themes/techdesignscouk/footer.php*.

    Right before the end-body element, I placed the code:

    < ?php wp_footer(); ?>

    Hope this helps!
  • Hi, I'm seen this errors in the Piwik Analytics section in the admin panel:


    Warning: unserialize() expects parameter 1 to be string, array given in /home/guillote/public_html/dementemarginal.com.ar/wp-content/plugins/piwik-analytics/piwikanalytics.php on line 284


    And

    Warning: unserialize() expects parameter 1 to be string, array given in /home/guillote/public_html/dementemarginal.com.ar/wp-content/plugins/piwik-analytics/piwikanalytics.php on line 65

    I'm using wordpress 2.6.
    Any ideas?
    Thanks!
  • @Agustin

    This probably is a bug. I will look at it and make a 2.6 release later this week. I first have to upgrade my own blog :)
  • I just checked in version 0.4. This version is Wordpress 2.6 compatible.

    Known issue: you probably have to re-set the plugin options. I am sorry for the inconvenience.


    Please let me know if there are any troubles or other issues. Thanks!
  • I already use a standalone installation of Piwik to track several sites. Not all the widgets work, but the most important ones I need do.

    Btw, I appreciate the work you do enough to have the link to the Piwik site in my Blogroll
  • I have few questions:

    1. As I activated the plugin, with piwik installed on server, how long it takes for stats to come up ... in 5 mins I had 0 traffic shown with plugin activated and set correctly.

    2. If I for the test purpose want to see if plugin works, and want to insert the code manually, having a wordpress blog, is inserting the code in footer.php is enough, or I need to insert it on all pages?

    3. In footer, should I insert it just above the:

    or - the last two codes on footer.php

    Tnx for the plugin and your assistance.
  • @E@zyVG

    I cannot answer your first question for sure. You might want to ask the developers at http://piwik.org/

    As for your 2nd and 3rd question: inserting the code in the footer.php code should work for most themes. Just check the page source. If it's in there, it works.

    The best place is to put the code just above the end-body tag.
  • Hi !

    I'm trying to get your plugin work on Aeros theme but I can't see any code on the pages :/
  • @Geobert
    The Aeros theme has a wp_footer call in the theme, so the function that displays the piwik code should be called.

    The code is called when you have set the site ID option, and are not admin. (or if you're admin and have admintracking on).
  • For your information: I have succesfully tested the plugin against wordpress 2.6.3.

    Both an upgrade and a fresh install went ok.
  • Volker
    Great plugin - just what I needed!

    It seems there is a minor bug.. in between the noscript tags the img url should be appended with ?idsite=x which is missing, at least in my install. So I had to add it by editing the php plugin file.
  • @Volker
    Thanks for your sharp eye, I will issue a bugfix release later this month.

    For 2009, after wordpress 2.7 comes out, I will add some more features, like piwik stats widgets for the admin dashboard. Stay tuned.
  • Version 0.5 is out!

    This is a bugfix release, that adds the idsite=x (see comment #31).
    It is tested against wordpress 2.6.5.

    Find bugs? Want new features? Please leave a comment. Thanks!
  • I am having a a problem, I have installed the plugin and seems to be ok. However I don't see any statistics. I am using the Simple Balance 2.1 CP theme and the code already exists in the footer but no joy.

    anything I could try to see where the problem is?
  • @Chris #37: When I look at your website, I see it tries to load the piwik script from http://piwiki.chrissparshott.com/

    That should probably not be piwiki, but piwik. :-)
  • Hi Jules,

    thanks a lot for this plugin. Do you know when you will release an upgrade for 2.7? Or is the current plugin already compatible?

    Thanks again and keep up the great work!
  • To all (and Patrick):
    I have tested the plugin with Wordpress 2.7.
  • darn it!!
  • Wonderful that this has been tested for Wordpress 2.7. Perhaps that could be updated on the WordPress plugins page as well? Thanks for your work on this. I look forward to using this open source alternative to Google Analytics.
  • @ArcherTC

    I updated the readme in the trunk, I cannot change the plugins page description without tagging it as a new release.

    Please find a bug, so I can make a new release ;-)
  • Hi,

    after installing the plugin in WordPress v2.7 I looked for the settings page for some time and could not find it. Finally I found it in the plugins and not in the settings section. Quite irritating! Rather than using the "add_submenu_page" function you should use "add_options_page".

    latz
  • @Latz
    Mh.. good point, I will put this on the list for the next release. Thanks for the feedback!
  • Hi Jules -
    Great work so far on this plugin! Wondering how close you are to having a new version with piwik stats available from the WP dashboard? Loving this plugin so far - I think this would really be a great feature..

    Thanks!
  • @scott
    Thanks! I am actually very close having a plugin that adds dashboard widgets. I have it ready for the visitors overview.

    But.. I ran into problems with my own Piwik installation shortly after that. Read: my database freezes. Rather than spending time fixing that, and finishing the plugin, I decided to stop using Piwik for the moment.

    If anyone is interested in finishing the plugin: drop me a line.
  • Hello, where do I find my site ID?
    I search on piwik.org for an add site option or register but I couldn't find anything.

    Cheers!
  • @alectro

    Log into your piwik administration. If you have admin rights you can find it under "settings". There is a "sites" tab there.

    Screenshot: http://twitpic.com/25sky

    In the first column it says "ID". That's your site ID.
  • Ok, new version is out: 0.6

    Changes:
    - moved the admin page to where plugins normally go (under plugins), thanks @Latz
    - tested for 2.7.1 and updated the compatibility in the readme.

    As always, leave a comment when you notice something odd, or if you have a question.
  • Thank you for the plugin!

    By the way: Although the readme file lists WordPress 2.5 as the minimum requirement the plugin seems to work perfect with my 2.3.3 installation.
  • Hi Jules,
    I set up piwik and your piwik plugin, entered the site ID (1).
    But I cannot see any piwik code in the source of my wordpress pages ... :-(
    How & where would I find it? I'd expected links to piwik.js and piwik.php ...?!
    Thanks,
    Stefan.
  • @Stefan

    I can see the Piwik tags perfectly on http://meta.wops.de/ - is that the site you're talking about?

    Try to log out as admin and take a look at your site then.
  • Hi Jules,

    no it's not about my site meta.wops.de. ;-) It's about another site (in an intranet, not via internet accessible).
    But your hint was great to look at the site when logged OUT as admin from WordPress! Didn't know that the "don't count admin requests"-mechanism works like that (don't include the piwik js at all then).
    Thanks! All fine now.

    Stefan.
  • @Stefan

    Glad it works. Might be an idea to show a html comment to the admin. It's almost the only question in the FAQ.
  • Awnist
    Hi. Thanks for your work. Haven't gotten it to work yet, but I'm interested in WPMU functionality. What are the possibilities of you making an automatic call to piwik to get a new site id with each plugin activation? it should probably mirror the wordpress site_id. If I have time to do this in the coming months, I will send you the code.
  • @Awinist
    Super, keep me posted!
  • Marek
    Hi,
    i would like to ask whether you plan to add a feature to your WP-Piwik integration plugin, that would allow to differentiate/exclude users(apart from admin) from statistics, since users can distort the length of visit statistics as they usually spend a lot of time writing articles or comments. It would be better to differentiate them, however I’m not sure whether it would be possible without modifying Piwik itself. Thanks for your great plugin! :)
  • Hi,
    I have written a patch for Piwik Analytics plugin that puts Piwik widgets into WordPress dashboard. Let's work together on this feature.
    Patch is embedded in this post (Post is in Turkish): http://mustafaulu.net/2009/04/23/wordpress-piwi...
  • @marek:
    You mean an extra checkbox 'track logged in users, too'? That shouldn't be too hard.

    @mustafa:
    Interesting. Like I said in an earlier comment: I have a working copy myself that shows piwik widgets. Only thing is that my own Piwik installation is broken and I don't have time to fix it.
    However, I will look at your patch further and contact you soon. Thanks!
  • Deaw
    How I will track outlinks from Link Cloaking Plugin?

    Thank for good plugin.
  • I have updated the plugin for the use with the lastest Piwik (version 0.4). If you are interested, just drop me an email.
  • Wordpress plugin not collecting stats with PiWik 0.4. I've checked the codes, and found out that there are discrepancies between the Javascript being generated by PiWik and the javascript being generated by the wordpress plugin. I guess that's the reason it's not working...
  • @AshKool Thanks for your comment.
    I have received Volker's code (see above) to make the plugin 0.4 compatible. I will work on the plugin to support both versions.

    I'll try to put a new release out before I go on holiday.
  • Frans
    Piwik looks nice and I will consider to use your plugin, but somehow I cannot figure out why no ip's are logged with piwik. I looked at the demo but somehow I'm missing information I really want to see and have.
  • Do you plan on updating the plugin in order to comply with the new JavaScript used by Piwik? The trouble is, that any other plugin tracks the admin too, which is frankly very bad.
  • crafty
    Hey, you all forget to say that piwik is very slow, using poor quality code and bad philosophy. Using it, you end up waiting minutes for a page to load and your visits will be shown after an hour IF you're lucky. If don't then they will never be shown, so I find piwik and over unflated piece of crap, right now, poorly coded but free.
    Well, that's my opinion, is actually free, but for real, you better pay a buck or two and have quality analytics than that. Nice try, piwik, but I fought with it for a week, debuging and trying to make it work faster, with no results. My logs just stopped registering, after 25, so how is that ? How it can be compared to GA ? Well, it simply can't since is not even working.
    Those guys who release such software, even if is free, should have some common sense and tell people about that and not marketing a complete useless crap as free, when is not even working. They should have some common sense to tell people about all the issues and in the first place, to release a software that actually works.
    Now, about my comments there will be some folks saying "well, but it's free what can you expect ?" ...well I expect it to work, at least cause no one needs free and useless stuff. Google Analytics is free also and it works, like many other free ones and franky, for a small fee, you better pay for an app that is working and don't lose time debugging poorly designed software. That doesn't help you but the opposite.
  • Is there any Java or .Net porting option available for Piwik? As I know there is nothing.

    Let me know if you know of any options?
  • Ok, I released Version 0.7 just now. This version only works for Piwik 0.4 and higher (it inserts the new tracking code), so please check before you upgrade.

    Also, I changed the options a bit, so re-set those.

    Questions? Bugs? Feature requests? Please drop a note. Thanks!
  • Hey Jules,

    Did you mean "Hostname of the piwik server (optional)" and "Base path of piwik installation" as a change in the options? I wonder if I have them set correctly.

    Settings are:
    ID: 2
    Track downloads: checked
    Hostname of the piwik server (optional):
    Base path of piwik installation: /data/htdocs/gray-um.com/admin/piwik/


    Wondering if this is correct. Using K2 as Theme, which has the footer.php addition needed before body element. But I do have my piwik in a https enviroment (also .htaccess but I configured it so the server doesn't need to auth).

    I'm not getting any data, might this be due to the https? or is it something in my configuration?
  • @Graham

    With base path, I mean the base URL path. Sorry for the confusion.

    You can use hostname: gray-um.com
    base path: /admin/piwik/

    On the https bit: if your blog is on http, the tracker code tries to use http as well. If it's https, it uses https. This to avoid browser warnings.
    There is currently no way in the plugin to force secure or regular http.
  • Mister Peabody
    What is this version .8 I see? What is new?
  • Version 0.8 is out. Tested for wordpress 2.8.2, and I changed some help messages to be more eh.. helpful.
  • @ crafty , maybe people like you should stay away from the internet if you can't get a simple, well-documented system like Piwik to work. Don't blame something for your own incompetence.
  • can you change the positioning of this message?

    "Piwik Analytics is not active. You must enter your Site ID for it to work."

    see here: http://img7.imageshack.us/img7/5200/changethis.png
  • @Dave: Fixed.

    New in version 0.9.1: this fix, and tested for WP 2.8.3
  • MB
    I think a direct link to the login page for the Piwik installation would be great.

    Here is what I did to add this quick link to the page.
    Insert at line#161



    Piwik Login Page
  • MB
    That didn't show up.

    The code would be something like this.


    < a h r e f="http://" target="_blank" >Piwik Login Page



    of course without the spaces
  • MB
    nevermind.
    keeps striping my spaced code even.
  • very useful for wordpress.but i want ask a question.is this plugin make slow the system?
  • @yarim, Never had a problem with piwik being slow, on the other hand, I have from time to time been annoyed with sites that are slowed down using GA. If I had only one site I wanted to track, I'd probably go with GA, but I host many sites on my server, and highly value piwik for this.
  • Is the heatmap also included in this wordpress plugin?

    cheerio
  • @Paul no, it is not.
    If you could provide me with a link to some documentation on that plugin (read: what to include on a page, etc) I can probably include it in an option.

    @MB: thanks for the tip, that would be helpful.

    @Yarim: Since you're adding code to the pages (and wordpress), there definitely is some overhead. However, this overhead is small, and the code is in the footer, so it won't hang your pages.
  • Hi, thx for the plugin, this is really useful. I've installed it on WP 2.8.4 without any problems so far (using Piwik 0.4.3). Just wanted to let you know as in the plugin-directory it still says "Compatible up to: 2.8.3".
  • mike
    I will try Piwik and this plug.
    Q:
    1. is the plugin ready to work with WP 2,8,4?
    2. if I uninstall plugin does the code on the pages go away?

    thanks

    mike
  • jeffrey
    Jules: will the plugin work with wordpress mu?

    thanks,
    jeffrey
  • very useful for wordpress.but i want ask a question.is this plugin make slow the system?
  • Even though I have not tested this plugin but I am going to try this soon on one of my blogs. I have mentioned about this plugin on my recent blog post at

    http://instantblogsolutions.com/blog-basics/wor...
  • Mark Heppner
    I think I found a bug, maybe. I'm using this plugin with the Free CDN plugin ( http://www.phoenixheart.net/wp-plugins/free-cdn/ ). I noticed that when the Piwki plugin is active, it puts an onClick event at the end of all outgoing links, so they can be tracked. However, when I active the Free CDN plugin, it adds, about 26 times, my domain and the CDN domain in front of the targeted outgoing link. By the way, that plugin uses the Coral CDN ( http://coralcdn.org ), which simply adds the domain .nyud.net to every image, and script. I think it's seeing the onClick events as a script that it tries to cache, but I'm not sure. Any ideas? Here's an example of what I am talking about (don't mind the mess, it's a theme I'm messing around with):
    http://markheppner.com/2009/10/jeff-mangum/?the...
  • @Mark
    Thanks for the detailed report. I've looked into it and as far as I can tell, it's not my plugin that is causing this.

    The onclick events for outbound page link tracking are not inserted by my plugin, but by the Google Analytics plugin.
    You can try to disable the outbound link tracking on that plugin and see if the problem persists.

    I haven't looked into this deeply, but glancing at the code of the other two plugins, it looks like the Coral plugin is misbehaving, simply because it's last in line modifying the page content.

    Hope this helps!
  • To all: I've tested this plugin against wordpress 2.8.4 without problems.

    I will update the compatibility in the readme at the next release.
  • Mark Heppner
    @jules

    I contacted the maker of that plugin, but I haven't gotten a response back. Thank you for your time and help!
  • Harry
    Hi,

    I sent you an email via the contact form on this site. Please help, I really want to use piwik and i know your plugin makes it easy!

    i installed piwik on domainA.com

    2 additional domains, so i have site id on the piwik > sites management 1 and 2

    if the domain i installed piwik on is "http://www.magicplugin.com/piwikfolder/", are these the right settings?
    - piwik site id = 1 or 2
    - Hostname of the piwik server = http://www.magicplugin.com
    - Base URL path of piwik installation = /piwikfolder/

    i do have the following setup but i don't see to be tracking anything as i see zeros for all stats in my piwik interface. how do i know i have piwik analytics configured properly? i don't need to add the additional javascript code to the footer of my wordpress blogs right?


    thank you!

    cheers
  • Just did a commit of version 0.9.2.

    Checked the plugin with WordPress 2.8.6. (it works), and added a link to your Piwik installation (see post from MB above).

    Please let me know if there are any problems. Thanks!
  • Steve
    Hi Jules,

    If I install Piwik at the top level directory "public_html", what should go in the base path?

    Should it just be blank or do I have to add the trailing slash?

    I tried testing both ways but I'm not logging any hits. Not sure if it's me or the install.
  • @steve
    Just a slash should be ok. Does the link below the settings ('check out your stats') link to the correct Piwik page?
    If not, post a link (here, or in the contact form) to your site, so I can have a quick look.
  • Steve
    Thanks Jules. The slash by itself worked.

    Not sure why Piwik didn't update immediately. Maybe it's not real time after all. I checked the documentation on the Piwik site about archiving but it's all too technical for me.

    Thanks for the help.

    One suggestion though. I noticed that the js that Piwik generates has noscript tags. Will you create a future version with noscript tags?
  • how can i tack my id site web?
  • See http://twitpic.com/25sky
    Go to settings -> sites and find your ID there. Good luck

    @Steve:
    That sounds like a reasonable request. I've made a note of it.
blog comments powered by Disqus