In today's digital age, website traffic analytics is essential for businesses to make informed decisions about their online presence. Google Analytics is the most popular free solution in this space, but it is not available as a self-hosted option. In a previous post, I covered Umami, a lightweight, open-source alternative. Today, I'll explore Plausible Analytics - another privacy-focused alternative - what it is, key capabilities, and how to deploy a self-hosted version on DigitalOcean.
What is Plausible Analytics?
Deploy Plausible on a DigitalOcean Droplet
For this walk-through, I'll use DigitalOcean; if you don't have an account, sign up here - you’ll receive a $200, 60-day credit when you add a valid payment method. Set up your team and project, and deploy the Docker 1-Click Droplet from the marketplace. This droplet includes the Docker CE and Docker Compose packages, along with their respective dependencies. In addition to package installation, the droplet also configures Docker according to the official recommendations. Click
Create Docker Droplet, select the data center region, the CPU option, an authentication option, the hostname, and click
Once the droplet is ready, select it and launch the
Droplet Console as root from the menu options. Run the following commands to clone the Plausible GitHub repo, install the required packages, and run the Plausible server.
# Download the Plausible GitHub repo git clone https://github.com/plausible/hosting cd hosting
In this directory, the
docker-compose.yml file installs and orchestrates networking between the Plausible server, Postgres and Clickhouse databases, and an optional SMTP server for email notifications. We are going to skip additional configuration, and use the defaults i.e. use local databases without email notifications. Look for the
plausible-conf.env file and update the following variables:
SECRET_KEY_BASE: random 64-character secret key used to secure the app.
BASE_URL: base URL where the Plausible instance is available, including the scheme (
https://), the domain name, and optionally a port if you don't wish to use the default
Generate the secret key value as follows and replace in the config file:
openssl rand -base64 64 | tr -d '\n' ; echo
The Plausible server runs on unencrypted HTTP by default and does not perform SSL termination. Let's set up a reverse proxy in front of the server using Caddy in the next section. First though, create a DNS A record
plausible.example.com in your DNS host that points to the droplet IP address, and update the
BASE_URL in the config file accordingly i.e.
Configure HTTPS with Caddy Server
Caddy is a powerful yet simple, Go-based open-source web server. Written in a memory-safe language, it compiles to a single, static binary, making it easy to run Caddy practically anywhere, even in containers. Caddy obtains and renews TLS certificates automatically, staples OCSP responses, and even performs automatic HTTPS rewrites. Let's install Caddy on the droplet first.
apt install -y debian-keyring debian-archive-keyring apt-transport-https curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list apt update && apt install caddy
Next, update the
docker-compose.caddy-gen.yml file under the
/hosting/reverse-proxy folder. Update the domain name and email address in the section below.
plausible: labels: virtual.host: "plausible.example.com" # change to your domain name virtual.port: "8000" virtual.tls-email: "firstname.lastname@example.org" # change to your email
docker compose to deploy all the components and start Plausible.
docker compose -f docker-compose.yml -f reverse-proxy/docker-compose.caddy-gen.yml up
Configure Your Website for Plausible Analytics
Once you launch the Plausible URL, you'll be greeted with the account registration page. Provide the admin account details, and click
Create my account.
Next, provide the domain/website that you want to monitor traffic for, and click
Add snippet. You can add more websites later.
That was a straightforward way to self-host a Plausible instance - a few final thoughts and considerations below:
- If you'd like to send transactional emails (e.g. account activation, password reset), see the SMTP server setup here.
- If you'd like to use a geolocation database other than the default
db-ipoption, see the guidance here.
- See this guide for information on getting the most out of your Plausible server.
- Finally, if you like Plausible but don't want to self-host the server, Plausible also offers a cloud-hosted option - compare the capabilities here.