Simple Goal & Conversion Tracking with Piwik: the Open Source Google Analytics Alternative |

Simple Goal & Conversion Tracking with Piwik: the Open Source Google Analytics Alternative

By Tad Chef / January 27, 2011

It’s not only the black hat and the paranoid who are increasingly wary of Google’s privacy issues. Google Analytics has come under attack repeatedly in Europe. Recently, German government officials even threatened to ​declare Google Analytics illegal.

While I consider Google Analytics a minor threat to privacy compared to other Google products and services (like Doubleclick, Google toolbar or Google Chrome), I think there is still room for improvement.

These and other reasons made me revisit Piwik, the open source, self-hosted Google Analytics alternative.

It’s a German project on top of that, so the solution is already there. I was testing Piwik two years ago in an early beta stage. Now it’s available in version 1.1.1 and already it’s quite a powerful web analytics solution.

Before we go on: Piwik can’t yet replace Google Analytics for most websites, either for entry level or professional​ users. On the other hand, it is an excellent tool for intermediate users – bloggers, for instance.

Once it’s installed, one of the truly outstanding advantages becomes apparent:  the goal tracking and management, or in other words the conversion tracking. It’s very easy to implement, easier than in Google Analytics or other web analytics tools if you ask me. Today I want show you how it works. Let’s use an average blog as an example.

You don’t have any goals to track on your blog? You have no conversions? ​You don’t sell anything on your blog?

Well, think again. I’m with Avinash Kaushik here:  you have to track so called micro-conversions. These are small things that show engagement or have some positive impact on your business. Typically on a blog you could track:

  1. Comments (comment submissions)
  2. Facebook likes​
  4. Delicious saves
  5. StumbleUpon shares
  6. RSS clicks (as in people trying manually to subscribe to your blog)
  7. Ad clicks
  8. Contact form submissions
  9. “About Us” or “Services” section visits

So you see there are plenty of ways in which you want to convert people even on a blog. Watching traffic trends is one thing, but tracking goals is a completely different way to find out what’s popular on your site.

I will show you three of them to start with:  comments, Delicious saves and “About” views. I chose these three for two reasons:  almost everybody has comments and an About Us page on their blog, and Delicious saves say quite a bit about your content. Furthermore, Piwik allows basically three ways of setting up goals. Each example shows one of them.

To add or edit goals in Piwik:

1. Click the “Goals” tab in the top menu.

Look for “Goals management” in the content part below.

2. Click “Create a new Goal” below.

A “Create a Goal” dialog like the one pictured below should appear:

Tracking “​About”

Let’s start with “About” as in “About Us”.  Why track “About”? Well, people clicking the About page express genuine interest in who you are and what you do. They are those visitors who might trust you in future based on the information you provide. That’s why tracking “About Us” visits makes sense as a micro-conversion.

3. Enter a “goal name”. I’d suggest “about view” as we track how often the About page has actually been viewed.

4. Check whether the radio button “Visit a given URL (page or group of pages)” is already selected, or select it.

5. Check whether “contains” is already selected in the drop down menu, or select it manually.

6. Add the file name of your About page in the input field right beside it. In case it’s something like you can add “/about”. In case you have more than one page or post starting with “/about” you can add a more exact part of the URL.

7. Click the button “Add goal”.

Tracking “​Delicious saves​”

Facebook likes and Twitter (re)tweets are great, but Delicious bookmarks are still the granddaddy of all social media engagement ways. ​Users who save your post on Delicious do it for their own sake; they want to read it later, save the resource for future reference or use it in some other way for themselves (I do it for publishing). Also, only an elite few use Delicious these days. Last but not least, Facebook and Twitter sharing does not mean much. People who share do so because they want to show it to others, not because they want to use a post for themselves.

3. Enter a “goal name”. I’d suggest “delicious save”, as we will track how many people have saved your site from a Delicious link on your site. Of course, you need a Delicious save link on your blog first. Most social media plugins provide one. Delicious itself offers tools to integrate it as well.

4. Select the radio button “Click on a Link to an external website” (the third one in the row).

5. Check whether “contains” is already selected in the drop down menu or select it manually.

6. Add the URL “” in the input field beside it, or check the actual URL your social media plugin links to and adapt it accordingly.

7. Click the button “Add goal”.

Tracking Comments

Why should you track comments? You can see them in the WordPress back end anyway, can’t you? Well, tracking comments with Piwik allows you to see which users engage with your blog, and thus which traffic is your most valuable based on measuring interaction. Hint:  it’s not the search or social media traffic.

Tracking comments is a bit more tricky than the other goals, but if you can customise WordPress themes you can do that as well.

3. Enter a “goal name”. I’d suggest “comment”, as we track comment submissions here.

4. Select “manually” in the “Goal is triggered” drop down menu.

5. Copy the “piwikTracker.trackGoal()” JavaScript call.

6. Click the button “Add goal”.

7. To find out the goal number of your “comment” goal, click the “Goal” tab again.

8. Scroll down and roll over the “Goal ‘comment’ ” link.

9. You see the following JS link “javascript:broadcast.propagateAjax(‘module=Goals&action=goalReport&idGoal=3’)” where the idGoal parameter is your goal number. Remember the number.

10. Add the number in your JS call in your WordPress theme comments.php.

It can be found in Appearance -> Editor -> Comments (comments.php).

Search for the “submit” button. My form submit button looks like this:

<input id="submit" name="submit" type="submit" value="<?php _e('Post Comment') ?>" tabindex="7" />

11. Add onclick="piwikTracker.trackGoal(3);" at the end of it so that it looks likes this:

<input id="submit" name="submit" type="submit" value="<?php _e('Post Comment') ?>" tabindex="7" onclick="piwikTracker.trackGoal(3);" />


Piwik not only allows you to set up goals easily, but also to get a quick and useful overview of which traffic converts best. Make sure you check out the “Conversions overview by segment” table view in the Goals tab. You have to scroll a bit to see it. It shows you which traffic sources, countries etc. perform best:

Piwik also has​ advanced privacy options:  you can both opt out of Piwik tracking if you want to enable the feature, and ​anonymise the last digits of the user IP. Google allegedly does this as well, but the data is sent to the US where, due to the patriot act, all kinds of government agencies can access it for a plethora of reasons. That’s why it’s basically already illegal in Germany. You are not allowed to send user data to another country. Furthermore, you’ll never now where your data is . Google has data centers all over the world, and I’m not sure it’s vulnerable to US secret services only.

With Piwik, which is self-hosted, you can decide yourself where your data is stored. It just depends on the location of your hosting. This big advantage is also a drawback. You need to install Piwik on your server or webhosting package. The process is largely automated, but nevertheless even I experienced some issues while installing it:  my FTP client had problems copying the ca. 5MB to my server and thus some files ended up being crippled. Instead of the installation page, I only saw garbled code on the page and rather unhelpful error messages.

Piwik is a software package for intermediate users. Ask yourself:  can I install a WordPress blog? If so, then you can install Piwik. Don’t know what your PHP and MySQL version is? Maybe you should stick with GA.

While Piwik is not yet a fully fledged Google Analytics alternative, it can compete quite well with popular entry level freemium or paid tools like Clicky, Woopra or Reinvigorate.

blog comments powered by Disqus
01865 703000