This help file explains how to setup the Goat Counter privacy-focused analytics program to track usage of your web site.
It's designed for advanced users and requires the use of the ssh and the command line.
Goat Counter will be installed on it's own, dedicated hosting order, not in the hosting order of the web site you would like to track. So, the first step is to create a new hosting order. In this example we will create a new hosting order with the domain stats.example.org
.
Note: If you plan to track multiple sites using a single goatcounter installation, you can! But, each site must have it's own unique domain name. So, for example, you could create a hosting order in which all of the following domain names are active:
site1.stats.example.org
site2.stats.example.org
site3.stats.example.org
In this example we are keeping it simple with just: stats.example.org
which allows you to track exactly one web site.
Once you have ecreate the new hosting order, be sure to follow the additional steps to add a web site and ensure you have an ssh user created.
Visit the releases page to find the most recent version of goat counter. You should find a link to the linux amd64 version, e.g. goatcounter-v2.5.0-linux-amd64.gz
.
While ssh'ed into your web site, change into the bin
directory and use wget to download the link you copied:
cd bin
wget https://github.com/arp242/goatcounter/releases/download/v2.5.0/goatcounter-v2.5.0-linux-amd64.gz
Then, gunzip it, rename it and fix the permissions:
gunzip goatcounter-v2.5.0-linux-amd64.gz
mv goatcounter-v2.5.0-linux-amd64 goatcounter
chmod 755 goatcounter
Then, create a symlink for easier access:
ln -s goatcounter-v2.5.0-linux-amd64 goatcounter
By default, goatcounter
will create a sqlite database in the db
directory of the current directory. We don't want to create the sqlite database in the bin
directory, so change into the include directory instead:
cd ~/include
Initialize your first site with:
goatcounter db newdb
goatcounter db create site -vhost stats.example.org -user.email you@example.org
Note: If you were tracking multiple sites, you would repeat this command for each site, with each site using a unique -vhost
argument, e.g. -vhost site1.stats.example.org
and then -vhost site2.stats.example.org
.
Now, run it by hand. You will need to pick a random port number that is greater than 1064 and less than about 65,000.
goatcounter serve -listen localhost:8240 -tls proxy
It should echo something like:
Feb 8 22:48:18 INFO: ready; serving 1 sites on "localhost:8081"; dev=false; sites: example.org
Now, go back to the control panel and edit your web configuration for your stats site.
Click the "Show Advanced Settings" button and, in the Settings field, enter:
ProxyPass / http://localhost:8240/
ProxyPreserveHost on
Be sure to use the same port number that you used when you launched goatcounter.
Now, open your browser and visit https://stats.example.org/
- you should be prompted to login with the email address and passowrd you set above.
Once it is up and running, you will want to create a systemd service to run it more reliable.
Start by hitting ctrl-c
in your terminal session to stop the service from running manually.
Then, in your hosting order, create a new scheduled job.
/home/sites/1234/bin/goatcounter serve -listen localhost:8240 -tls proxy
forever
/home/sites/1234/include
How you do that depends on your web site.
Goat Counter provides a WordPress Plugin.
Or, you can add the javascript provided at the top of your goat counter web page to each page on your web site.