How to Install Fathom website analytics tool on Ubuntu / CentOS / Arch Linux
source link: https://computingforgeeks.com/how-to-install-fathom-website-analytics-tool-on-ubuntu-centos-arch-linux/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
In this blog post, you’ll learn to install and use the Fathom Analytics tool on Linux – Ubuntu 18.04 / Ubuntu 16.04 / CentOS 7 / Arch Linux e.t.c. Fathom Analytics is an open source, easy to use and more privacy-focused alternative to Google Analytics.
This tool will help you collect information on the internet about any web service, can be for service/content improvement, historical analytics e.t.c. Your data and all users’ privacy are kept private by this free tool. Furthermore, Fathom respects the privacy of your users and does not collect any personally identifiable information.
How to Install Fathom website analytics tool on Linux
Download the latest release of Fathom with wget
wget https://github.com/usefathom/fathom/releases/download/latest/fathom-linux-amd64 -O fathom
Make the file executable
chmod +x fathom
Move the binary file to /usr/local/bin
directory
sudo mv fathom /usr/local/bin
Use option--help
to print help page.
$ fathom --help INFO[0000] Fathom 1.0.1 NAME: Fathom - simple & transparent website analytics USAGE: fathom [global options] command [command options] [arguments...] VERSION: 1.0.1 COMMANDS: server, s start the fathom web server register register a new admin user stats view stats help, h Shows a list of commands or help for one command GLOBAL OPTIONS: --config FILE, -c FILE Load configuration from FILE (default: ".env") --help, -h show help --version, -v print the version
How to Use Fathom
Before you can start using Fathom, you need to register your user account
$ fathom register --email=<email> --password=<password>
Sample output
NFO[0000] Fathom 1.0.1 WARN[0000] Error reading configuration. File `.env` does not exist. INFO[0000] Connected to sqlite3 database: /home/jmutai/fathom.db?_loc=auto INFO[0000] Created user [email protected]
Read more about Fathom Configuration file to understand all possible configuration values.
Starting the Fathom web server
Create a .env
configuration file named with the following contents.
FATHOM_SERVER_ADDR=9000 FATHOM_DEBUG=true FATHOM_DATABASE_DRIVER="sqlite3" FATHOM_DATABASE_NAME="fathom.db" FATHOM_SECRET="random-secret-string"
Once you have Fathom configured, you can start Fathom web server using the command fathom server
.
fathom server
This should start serving up a website on port 9000 using an SQLite database file named fathom.db
.
Manage Service with systemd
To ensure the Fathom web server starts on the system reboot, we should use Systemd.
Create a new file called /etc/systemd/system/fathom.service
with the following contents. Replace $USER
with your actual username.
[Unit] Description=Fathom server management service unit Requires=network.target After=network.target [Service] Type=simple User=$USER Restart=always RestartSec=3 WorkingDirectory=/home/$USER ExecStart=/usr/local/bin/fathom server [Install] WantedBy=multi-user.target
Reload the Systemd configuration and enable the service start on boot.
sudo systemctl daemon-reload sudo systemctl enable fathom.service
Start Fathom web server by issuing the following command.
sudo systemctl start fathom.service
The service should start and switch to a running status.
Open the link http://server-ip-address-here:9000 to access Fathom dashboard.
Running Fathom with NGINX
Install nginx on CentOS
sudo yum install epel-release sudo yum install nginx
Install nginx on Ubuntu / Debian
sudo apt-get install nginx
Install nginx Arch
sudo pacman -S nginx
We then use NGINX to redirect all traffic for a certain domain to our Fathom application running on port 9000 by using the directiveproxy_pass
.
Create the following file in /etc/nginx/conf.d/fathom.conf
server { server_name fathomsite.com; location / { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:9000; } }
Test configuration syntax and restart nginx
sudo nginx -t sudo systemctl enable nginx sudo systemtl restart nginx
Open the link http://fathomsite.com to access the Fathom dashboard.
Login with the configured email address and password
Tracking snippet
To start tracking, include the following JavaScript on your site and replace yourfathom.com
with the URL to your Fathom instance.
<!-- Fathom - simple website analytics - https://github.com/usefathom/fathom --> <script> (function(f, a, t, h, o, m){ a[h]=a[h]||function(){ (a[h].q=a[h].q||[]).push(arguments) }; o=f.createElement('script'), m=f.getElementsByTagName('script')[0]; o.async=1; o.src=t; o.id='fathom-script'; m.parentNode.insertBefore(o,m) })(document, window, '//yourfathom.com/tracker.js', 'fathom'); fathom('trackPageview'); </script> <!-- / Fathom -->
For a WordPress website, use Fathom WordPress Plugin
- In your WordPress admin panel, go to Plugins > New Plugin, search for Fathom Analytics and click “Install now“
2. Alternatively, download the plugin and upload the contents of fathom-analytics.zip
to your plugins directory, which usually is /wp-content/plugins/
.
After installing and activating this plugin, go to Settings > General and enter the URL to your Fathom instance in the text field near the bottom.
After a few minutes, the analytics should start showing.
Thanks for using our guide to setup your personal analytics engine powered by Fathom. For any query drop a comment and I’ll be happy to respond.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK