Open Source Web Analytics Tool Piwik

Publish: 2017-06-20 | Modify: 2017-06-21

Piwik is a web analytics tool developed using PHP and MySQL. It can provide real-time statistics on website visits and is comparable to Baidu Analytics, CNZZ Analytics, and Google Analytics. Piwik can be hosted on your own server.

admin-piwik_video

Download and Installation

Assuming you already have a basic understanding of website setup, I won't go into detail about the installation process. I'll just share some issues I encountered during my own installation.

The installation process is straightforward, and the official documentation is very detailed. One thing to note is that Piwik requires support for the shell_exec function, which is disabled in most environments. To enable this function, you need to modify the php.ini file and restart your web server.

Setting the Language to Chinese

Piwik supports multiple languages, but the default interface is in English. You can change it to Chinese in the backend. Go to Personal - Settings - Language and select Simplified Chinese, then save. See the screenshot below.

snipaste_20170620_175613

Using HTTPS

To prevent man-in-the-middle attacks and for security reasons, it is recommended to use HTTPS for accessing Piwik. In addition to correctly configuring SSL certificates in your web server (e.g., nginx), you also need to add the following line to config/config.ini.php in your site directory, after the [General] section:

assume_secure_protocol = 1

If you are unsure how to apply for an SSL certificate, please refer to the following articles:

Obtaining the Real IP Address

If your website or Piwik is using a CDN, you may notice that Piwik is only recording CDN node IP addresses, which is not ideal for analysis. Fortunately, the Piwik team has already considered this issue. You can refer to the article "Methods for Obtaining the Real IP Address in PIWIK" to solve this problem.

IP Tracking

By default, Piwik's IP tracking is not very accurate. It can only determine the country and cannot pinpoint the city based on the IP address. The official solution is to use the GeoIP database to improve accuracy.

  • Download the GeoIP database: GeoLiteCity.dat.gz
  • Place the database in the misc directory of your website
  • Unzip the database using the command gzip -d GeoLiteCity.dat.gz
  • Enable GeoIP support in Piwik by going to System - Geolocation - GeoIP (Php). See the screenshot below.

snipaste_20170620_181330

Conclusion

With Piwik, you can add websites in the Piwik backend and add the generated JavaScript code to your sites to enjoy powerful analytics capabilities similar to Google Analytics. Piwik is especially suitable for small and medium-sized websites and solves the problem of slow loading of Google Analytics in China. If you're interested, give it a try.

Piwik also offers a mobile app for easy access to real-time data on your phone.

However, it was found that many "undefined keywords" appeared in the search sources. Searching online, I found that this issue is not unique to me. The explanation given by users is that no analytics tool can accurately track all search terms, perhaps due to competition among analytics tools causing mutual blocking.


Comments