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.
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.
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.
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:
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.
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.
misc
directory of your websitegzip -d GeoLiteCity.dat.gz
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.
I come from China and I am a freelancer. I specialize in Linux operations, PHP, Golang, and front-end development. I have developed open-source projects such as Zdir, ImgURL, CCAA, and OneNav.