Having analytics about your website is useful. You want to know how many people visit your website, when they visit, what page they like reading, and where they came from. The most popular solution by far to do this, is Google Analytics.
Google Analytics tracks your user with cookies and follows them around to serve them ads later. Google Analytics has lots of functions that I (and probably you) never use. Those features are still there though. So when you decide to use Google Analytics, it slows down your website significantly.
That's why I have decided to make the switch to Plausible Analytics. Plausible provides simple andprivacy-friendly analytics. For you, that means lots of good things. Both as a visitor of my website, and as a CKX website owner yourself.
- Website with Plausible are faster, because the analytics are simpler.
- Visitors on the website are not tracked, privacy is a main focus.
- No need for annoying cookie banners (no cookies needed because there is no tracking).
- Fully compliant with GDPR, CCPA and PECR (major privacy laws).
- Made and hosted in the EU.
There are two main ways to use Plausible Analytics:
- Using their European-owned cloud infrastructure
- Hosting an instance of Plausible yourself
The former is a lot easier to get started with. Additionally, you sponsor a great company that pushes privacy analytics forward. Since Plausible doesn't track its users and thus can't (wouldn't) sell visitors data, they are funded through subscription costs.
If you have some time to do the set up, you can use Plausible for free. You will need to host Plausible on your own cloud infrastructure and manage updates. That's what I did, and I'll tell you how I did it in this article.
My server setup
My server setup is - in line with my analytics solution - simple. I'll keep things short here, as I plan to write a more elaborate article on how I build and host websites. Most websites I host are on Cloudflare's network. Cloudflare Pages, Functions, Workers, and KV power all of my web projects as long as they can handle them.
Even though Easypanel is Docker-focused, at the time of writing there is no direct support for Docker-compose files. A very quick summary for people who don't (fully) understand Docker: with Docker, you can describe how to run a system. A system can be your website, a database, or something else. With Docker-compose, you can list which Docker images (= which systems) your total project needs.
Plausible provides a Docker-compose, but Easypanel doesn't understand it. That means some more manual work is needed. Fortunately, the community around Easypanel is great. The user ravenbroetzmann wrote a tool aptly named Compose to Easypanel. It, you guessed it, converts Docker-compose files to a format that Easypanel can understand.
That brings us to the second bump in the road. The Docker-compose, even translated through the converter tool, was not compatible. Easypanel errored when trying to use the converted instructions.
The Easypanel community comes to the rescue again. After I posted the error I just mentioned to the Easypanel community support and explained my goal of trying to install Plausible on Easypanel, some users didn't hesitate to investigate the issue.
Users Derock and Supernova3339 went back and forth to discuss solutions on how to get Plausible to run. And not even a day later, these magick words were posted: "Holy!! I got it working!!!".
Supernova3339 was then very friendly to walk me through the newly found steps to self-host Plausible on a server running Easypanel. And I'll summarise that for you here.
Installing Plausible on Easypanel
The official self-hosting documentation of Plausible can be found on their website. These instructions are abreviated and specific to Easypanel.
To get started, create a new project on your Easypanel server (you could call it
plausible). You'll need three services (like the systems I talked about when explaining Docker-compose):
- A Postgres database (to store user information)
- Clickhouse database (to store analytics information)
- Plausible itself
Adding Postgres as a service on Easypanel is the easiest step. In your new project, create your first service. There, you can directly select Postgres. Give it a name you like, and set the Docker image to version 14:
That's it! You'll need the internal connection URL later, so you can copy that now already if you like. Go to the Postgres service and in the credentials section, you can copy the Internal Connection URL by clicking on it.
Installing Clickhouse is a bit more involved. Create your second service in your project. Since there's no native support for Clickhouse in Easypanel, you'll select the generic App as service type. Give it an appropriate name like
clickhouse so you can easily recognise it later.
The source for this service will be a specific version of Clickhouse. Go over to the source section, select Docker Image and in the image field, type
clickhouse/clickhouse-server:22.6-alpine and click save.
Next, go over to Domains > Proxy and set the Application Port to 8123.
Lastly, you have to add some Docker mounts. Go to Advanced > Mounts on your Clickhouse service and add the following:
- A volume mount with name
event-dataand mount path
- A file mount with mount path
/etc/clickhouse-server/users.d/logging.xmland contents below
- A file mount with mount path
/etc/clickhouse-server/config.d/logging.xmland contents below
I suggest you save these already without their contents to be safe. The contents for these file mounts are the following.
Contents for file mount at /etc/clickhouse-server/users.d/logging.xml:
Contents for file mount at
<!-- Stop all the unnecessary logging -->
And make sure to save (again) after you added the file mount contents. You can now deploy the Clickhouse service, it should think for a little while and then show you a green dot in Easypanel to indicate that it deployed succesfully.
The last step of this process is to add Plausible as a service in the Easypanel project. Again, this isn't native to Easypanel so you'll add an App-type service. This time, please dedicate a URL (domain or subdomain) to your analytics instance and add it to the service. As the source, you have to use
plausible/analytics:latest (or a specific version if you don't want to auto upgrade on restarts), which is the first party native Docker image.
The only thing left to do is adding the environment variables. To do that, go to the Environment tab, and add these:
BASE_URL: the full URL that you chose. For example:
SECRET_KEY_BASE: a random secure key. Run
openssl rand -base64 64 | tr -d '\n' ; echoor get one here.
DATABASE_URL: the internal connection URL from your Postgres database, you may have copied earlier.
CLICKHOUSE_DATABASE_URL: In general, that is
http://[project_name]_[clickhouse_service_name]:8123/default. For me, that was
Optionally, you can add SMTP configuration variables so Plausible can send emails. I did this, and am using Mailgun as my email provider. Your credentials will vary based on what you use. The environment variables you need are listed in Plausible's documentation. I used these:
Note that Plausible recommends to add an admin user with environment variables. I forgot to do this, and registered through the regular signup instead when Plausible was running. Use
ADMIN_USER_NAME (eg "John Doe"),
ADMIN_USER_PWD for that.
Additionally, I set
invite_only so my Plausible instance is not just for anyone to create an account and start using.
When these are all entered, save the environment variables and deploy the service. That's it, after a few seconds of thinking you should see logs without errors and a green dot on Eayspanel indicating that Plausible is up and running 🥳.
Possible problems and fixes
Unfortunately for me, that was not the case. My logs were showing errors. After some thinking and googling, the fix turned out to be that I needed to initialise my database myself through a Docker startup command. I added the following in my Plausible service > Advanced > Deploy > Command:
sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
Another thing I tried before I found that, but didn't help for me, is installing a translation layer for architectures. Depending on your system, this may help for you. SSH into your server and run this (as sudo):
docker run --privileged --rm tonistiigi/binfmt --install all