Excluding yourself from your Piwik Logs

What is Piwik?

Piwik is a web analytics software similar to the omnipresent Google Analytics. I chose Piwik instead of Google Analytics as I wanted a self-hosted solution instead of yet another third-party service. As a bonus, Piwik is licensed under GPLv3. It is always heartening to see high quality free software.

So, while Piwik works great for its intended task of providing analytics, I found that it was tracking my visits to my website too. This is not good, as it pollutes the actual useful data such as, how many people visit the website, time spent by the visitors on the website, etc.

Excluding yourself from being tracked

Thankfully, Piwik provides multiple ways to exclude yourself from being tracked.

First log in to your Piwik account and go to Settings -> Websites. There are two options available on this page.

  • Global list of Excluded IPs

    First option is to add your IP to the "Global list of Excluded IPs". Unfortunately, this only works with static IPs, and most home users, including me, are assigned dynamic IPs these days. So, this option was ruled out.

  • Global list of user agents to exclude

    Second option is the "Global list of user agents to exclude". This option isn't really meant to prevent yourself from being tracked, since browser user-agents are usually common for millions of people. It is basically meant to exclude certain bots from being logged. One way you can use this feature for yourself is by assigning a unique user-agent to your browser, something different than the default. But I decided against this, as I would become uniquely identifiable all over the web too.

Note: Some browser addons let you specify user-agents on a per-website basis. The above option can be used if you use such an addon.

Setting an Ignore cookie works!

Another option is to go to Settings -> User settings. Here you can set an "ignore" cookie on your browser which tells Piwik not to track your visits.

So, I decided to opt for this option, but this also meant that I couldn't clean my browser cache, as I regularly do. I worked around this by creating a dedicated Firefox profile for visiting my own website and setting it to retain the cookies.

But the problem is not fully solved

The above solution did solve the problem of ignoring my visits to my website. But, while viewing the logs in Piwik, I found that it had a lot of entries with the title and my IP next to them. I realized that these entries were made when I was testing the website on my local computer.

This gave rise to the following question:

Why was my local activity being logged by Piwik which resides on the remote server?

I realized that, whenever I compile the website using Nikola, it embeds the Piwik code in all the pages. I first test out the new posts on the local computer and then deploy them to the server. But, while testing the website locally, the browser was contacting the Piwik installation on the server (due to the embedded code). This was a bigger issue than the previous one, since I spend a lot of time writing and perfecting the posts locally, and all this time was being logged by Piwik.

Prevent Piwik from logging your activity on your local computer

Since the logs were showing and I am such a genius, I tried adding to the "Global list of Excluded IPs". This failed obviously, since my IP was not, rather the dynamic IP assigned to me by my ISP.

Then I tried to manually create a cookie for with the same content as the Piwik "ignore" cookie. But this too failed, since Piwik was not running on localhost, but on my public server instead.

RequestPolicy to the rescue

After a lot of thinking I realized that the solution was with me all this time. I use a Firefox addon called RequestPolicy, which lets us decide which cross-site requests to allow. I simply set it to block connections from to my web server and voilà, problem solved!

So, I finally managed to solve both problems, using different methods, but both of them involved manipulating the browser.


Comments powered by Disqus