If you need a self-hosted analytics platform, Fathom web analytics maybe just what you want. It’s a great alternative to Google analytics and other platforms available today, because it’s simple, transparent, open source and 100% free to use without limits.
Fathom is an opensource analytics platform with simple web interface. It provides full website analytics for small and medium size businesses. When you want to take full control of your own website analytics and data without using third party solutions, like Google Analytics, then Fathom is a great place to start.
Fathom maybe the only web analytics that gives you full control over your data and more:
- Free open-source software
- 100% data ownership
- User privacy protection
- User-centric insights
- Customisable and extensible
- Easy to use
- No data limits
This brief tutorial is going to show students and new users how to install Fathom on Ubuntu 16.04 and 18.04.
For more on Fathom, please vist its home pageTo setup Fathom, follow the steps below:
Step 1: Install MariaDB Database Server
MariaDB database server is a great place to start when looking at open source database servers to use with Magento. To install MariaDB run the commands below.
sudo apt update sudo apt-get install mariadb-server mariadb-client
After installing MariaDB, the commands below can be used to stop, start and enable MariaDB service to always start up when the server boots.
Run these on Ubuntu 16.04 LTS
sudo systemctl stop mysql.service sudo systemctl start mysql.service sudo systemctl enable mysql.service
Run these on Ubuntu 17.10 and 18.04 LTS
sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
After that, run the commands below to secure MariaDB server by creating a root password and disallowing remote root access.
sudo mysql_secure_installation
When prompted, answer the questions below by following the guide.
- Enter current password for root (enter for none): Just press the Enter
- Set root password? [Y/n]: Y
- New password: Enter password
- Re-enter new password: Repeat password
- Remove anonymous users? [Y/n]: Y
- Disallow root login remotely? [Y/n]: Y
- Remove test database and access to it? [Y/n]: Y
- Reload privilege tables now? [Y/n]: Y
Restart MariaDB server
Now that you’ve installed all the packages that are required for Fathom to function, continue below to start configuring the servers. First run the commands below to create a blank Magento database.
To logon to MariaDB database server, run the commands below.
sudo mysql -u root -p
Then create a database called fathom
CREATE DATABASE fathom;
Create a database user called fathomuser with new password
CREATE USER 'fathomuser'@'localhost' IDENTIFIED BY 'new_password_here';
Then grant the user full access to the database.
GRANT ALL ON fathom.* TO 'fathomuser'@'localhost' IDENTIFIED BY 'user_password_here' WITH GRANT OPTION;
Finally, save your changes and exit.
FLUSH PRIVILEGES; EXIT;
Step 3: Download Fathom Script
One can use Fathom Analytics simply by downloading its install script on Linux machine. to do that, run the commands below:
cd /tmp wget -O fathom
After downloading the script, run the commands below to make it executable and move it to the bin directory.
sudo chmod +x fathom
Then move it to the default local bin directory.
sudo mv fathom /usr/local/bin
That should allow you to use Fathom on Linux systems, including Ubuntu.
Step 2: Setting Up Fathom
Before you can use Fathom, you must first create an account. run the commands below to create and account to use via its web portal.
fathom register --email=[email protected] --password=new_password_here
That should create an account for the admin account.
All configuration in Fathom is optional. If you supply no configuration values then Fathom will default to using a SQLite database in the current working directory.
Most likely, you want to use MySQL or PostgreSQL if you’re planning on running Fathom for longer periods of time though..
To do so, either create a .env file in the working directory of your Fathom application or point Fathom to your configuration file by specifying the –config flag when starting Fathom.
Run the commands below to create Fathom evironment configuration file in your home directory.
cd nano .env
Then copy and paste the content below replacing your database name and password you created above.
FATHOM_SERVER_ADDR=9000 FATHOM_DEBUG=true FATHOM_DATABASE_DRIVER="mysql" FATHOM_DATABASE_NAME="fathom" FATHOM_DATABASE_USER="fathomuser" FATHOM_DATABASE_PASSWORD="new_password_here" FATHOM_DATABASE_HOST="localhost" FATHOM_DATABASE_SSLMODE="" FATHOM_SECRET="random-secret-string"
Save your changes and continue.
Once you’ve configured the settings above, run the commands below to start Fathom server.
fathom server
That should start up the server and begin listening on port 9000.
INFO[0000] Fathom 1.0.1
INFO[0000] Configuration file: /home/richard/.env
INFO[0000] Connected to mysql database: fathomuser:new_password_here@tcp(localhost)/fathom?loc=Local&parseTime=true
INFO[0001] Applied 4 database migrations!
INFO[0001] Server is now listening on :9000
Now open your browser and browse to the server hostname or IP address followed by port #9000
To ensure that Fathom starts automatically when you boot your server, create a system service account.
Run the commands below to create one for Fathom.
sudo nano /etc/systemd/system/fathom.service
than add the content below into the file and save.
[Unit] Description=Fathom server management service unit Requires=network.target After=network.target [Service] Type=simple User=richard Restart=always RestartSec=3 WorkingDirectory=/home/richard ExecStart=/usr/local/bin/fathom server [Install] WantedBy=multi-user.target
Save the file and exit.
After that, run the commands below to enable Fathom service.
sudo systemctl daemon-reload sudo systemctl enable fathom.service
This is the code you’ll want to add to your web pages if you want to gather information about your website.
<!-- Fathom - simple website analytics - -->
<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 more on configuring Fathom, check out its Github page.
Enjoy!
You may also like the post below: