Alternatives to Google Analytics?

What web analytics package do you recommend as an alternative to Google Analytics? I see there is a tutorial on piwik, but it is 4 years old and out of date. Specifically, I need something that will work with nginx on Ubuntu (my site is running Node). Any chance you’d create a tutorial?

What do you use to track web traffic on your site?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer


Awesome, you’re 90% there already :-).

Essentially, what we’d do is create a similar server block and modify it to work with PHP-FPM. I’ll use in this example, but you’re free to modify it.

First thing you want to do is install your PHP packages. Since you’re using Ubuntu, that can be done using apt-get.

I generally install most all available packages, so the initial install command would be:

apt-get -y install php7.0-bcmath php7.0-bz2 php7.0-cli php7.0-common php7.0-curl php7.0-dev php7.0-enchant php7.0-fpm php7.0-gd php7.0-gmp php7.0-imap php7.0-interbase php7.0-intl php7.0-json php7.0-mbstring php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-pspell php7.0-readline php7.0-recode php7.0-soap php7.0-sqlite3 php7.0-tidy php7.0-xml php7.0-xmlrpc php7.0-xsl php7.0-zip

That’ll handle pretty much everything, including what’s required by PiWik.

With PHP-FPM installed, now we need to focus on the server block itself. Since we should be using SSL, I’ll be setting up a near identical server block as what you’re already using and modifying it for PHP.

    listen 80;
    listen [::]:80;
    return 301 https://$server_name$request_uri;

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    include snippets/;
    include snippets/ssl-params.conf;

    root /var/www/html/stats;

    index index.html index.htm index.nginx-debian.html;

    location / {
        try_files $uri $uri/ /index.php?$args;

    location ~ /.well-known {
        allow all;

    location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        fastcgi_index index.php;

        include fastcgi_params;

I recommend wiping fastcgi_params and adding the configuration below. To do that, we can run:

truncate -s 0 /etc/nginx/fastcgi_params


nano /etc/nginx/fastcgi_params

Now copy and paste the following to that file:

fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 512k;
fastcgi_buffers 512 16k;
fastcgi_busy_buffers_size 1m;
fastcgi_temp_file_write_size 4m;
fastcgi_max_temp_file_size 4m;
fastcgi_intercept_errors off;

fastcgi_param SCRIPT_FILENAME   $request_filename;
fastcgi_param PATH_INFO         $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED   $document_root$fastcgi_path_info;
fastcgi_param QUERY_STRING      $query_string;
fastcgi_param REQUEST_METHOD    $request_method;
fastcgi_param CONTENT_TYPE      $content_type;
fastcgi_param CONTENT_LENGTH    $content_length;
fastcgi_param SCRIPT_NAME       $fastcgi_script_name;
fastcgi_param REQUEST_URI       $request_uri;
fastcgi_param DOCUMENT_URI      $document_uri;
fastcgi_param DOCUMENT_ROOT     $document_root;
fastcgi_param SERVER_PROTOCOL   $server_protocol;
fastcgi_param REQUEST_SCHEME    $scheme;
fastcgi_param HTTPS             $https if_not_empty;
fastcgi_param HTTP_PROXY        "";
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE   nginx/$nginx_version;
fastcgi_param REMOTE_ADDR       $remote_addr;
fastcgi_param REMOTE_PORT       $remote_port;
fastcgi_param SERVER_ADDR       $server_addr;
fastcgi_param SERVER_PORT       $server_port;
fastcgi_param SERVER_NAME       $server_name;
fastcgi_param REDIRECT_STATUS   200;

Now you’d create a MySQL database and user for PiWik and extract the PiWik files to the directory you’ve defined. I used /var/www/html/stats but you could use anything.

Once the files are uploaded, you need to set their ownership to www-data. To do that, we can run:

chown -R www-data:www-data /var/www/html/stats

That’ll only change permissions on stats and all files and directories within it, it’ll leave /var/www/html alone (which is what we want).

Now, once you’ve setup an SSL certificate for the sub-domain and created the proper A and CNAME entries to make sure it points to your installation, all you need to do is restart NGINX and load the sub-domain to get the installer started.

If you run in to any errors, check the error log:

tail -20 /var/log/nginx/error.log

You can post any errors as a reply and I’ll do my best to help you troubleshoot them.

That said, I would recommend changing your second server block and swapping:

server_name _;



so that it matches your first block. That’ll work for NGINX when there’s only one server block, but it can potentially cause issues when you start adding multiple domains, sub-domains, etc.

Always make sure your Port 80 server blocks match your Port 443 server blocks. It’ll save you a ton of troubleshooting down the road.

You may want to check Countly, which is installable on-premises and available as a hosted platform. You have two options to deploy:

  1. (easy way): Using DO 1-click installer, create your own Countly Community instance on Digital Ocean.
  2. Download Countly Community Edition on Github and run on your own DO server, which is quite a straightforward process.

You can use Countly to track both web pages and mobile apps, as well as desktop apps.


This comment has been deleted

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    Featured on Community

    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

    Become a contributor

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

    Learn more
    DigitalOcean Cloud Control Panel