Since Google Analytics switched to GA4 it kinda stopped working. Data reported is not accurate anymory. Majority of traffic is not captured since every adblocker blocks Google Analytics scripts.
I won't continue why Google Analytics is rubish you already know that.
Presenting Plausible analytics, ta-da!
What is Plausible?
Plausible is an open source Google analytics alternative. You can run if for free 100% or if you don't want to self-host it you can pay cloud version.
What are the benefits of using Plausible analytics?
Short list goes like this:
- If it's self-hosted it won't be blocked by adblockers
- You'll capture almost entire traffic
- It is fast
- You can do whatever you want with the data
- You can track unlimited number of sites
Additional benefits are easy configuration for goals, WordPress plugin which can be connected to self-hosted Plausible and many more.
Why self-host Plausible?
First it'll be served from a custom domain, so it won't be blocked by adblockers.
Second, it's free (if you've a server or VPS already).
How much does it cost to host Plausible
Cheapest VPS on Hetzner is ~$4/month.
What's great thing when you own the server is that you can host anything else on it. You can host multiple applications, not only Plausible.
So your cost is going down.
Hosting Plausible on Hetzner using Coolify
Coolify is a script which allows you to host multiple applications on the same server.
You can host anything with it. I won't go into details about how Coolify works, since I want to focus on Plausible here.
First thing is to create a VPS on Hetzner and choose Ubuntu 22.04 for OS.
You may notice in the video I configured an SSH key, if you don't know how to get the key checkout SSH key setup.
Install Coolify on the server
Now we need to SSH into the server, if you're new to this see above SSH link.
As a root user, we need to run:
curl -fsSL https://cdn.coollabs.io/coolify/install.sh | bash
This command will install Coolify on our Ubuntu 22.04 server.
After few minutes installation will be over and you'll see success message with a link:
Register on Coolify
When you visit provided URL you will be presented with the registration form.
Choose some secure password since this account will have control over every app hosted on Coolify.
Create new Coolify project for Plausible
Coolify navigation could be a bit strange for newcomers, but follow my steps here and there we'll be no problems.
In the sidebar locate projects button and click on it.
Smash +Add button to create a new project.
Open new Coolify project
After it's created go and click on the new project.
Select Coolify environment
When you're inside new project you'll have 1 existing environment, that'll be production
.
Go into the production environment.
Inside we need to add new Resource.
Resource is the actual application we want to run on this environment. In our case it's Plausible Analytics.
Installing Plausible using Docker compose script
On new resource page we need to select Based on Docker Compose option.
In the input for Docker Compose script paste this code:
# ignore: true
# documentation: https://plausible.io/docs/self-hosting
# slogan: "Plausible Analytics is a simple, open-source, lightweight (< 1 KB) and privacy-friendly web analytics alternative to Google Analytics."
# tags: analytics, privacy, google, alternative
version: "3.3"
services:
plausible:
image: plausible/analytics:v2.0
command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
environment:
- DATABASE_URL=postgres://postgres:$SERVICE_PASSWORD_POSTGRES@plausible_db/plausible
- BASE_URL=$SERVICE_FQDN_PLAUSIBLE
- SECRET_KEY_BASE=$SERVICE_BASE64_64_PLAUSIBLE
depends_on:
- plausible_db
- plausible_events_db
- mail
mail:
image: bytemark/smtp
plausible_db:
image: postgres:14-alpine
volumes:
- db-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=plausible
- POSTGRES_PASSWORD=$SERVICE_PASSWORD_POSTGRES
plausible_events_db:
image: clickhouse/clickhouse-server:23.3.7.5-alpine
volumes:
- type: volume
source: event-data
target: /var/lib/clickhouse
- type: bind
source: ./clickhouse/clickhouse-config.xml
target: /etc/clickhouse-server/config.d/logging.xml
read_only: true
content: >-
<clickhouse><profiles><default><log_queries>0</log_queries><log_query_threads>0</log_query_threads></default></profiles></clickhouse>
- type: bind
source: ./clickhouse/clickhouse-user-config.xml
target: /etc/clickhouse-server/users.d/logging.xml
read_only: true
content: >-
<clickhouse><logger><level>warning</level><console>true</console></logger><query_thread_log
remove="remove"/><query_log remove="remove"/><text_log
remove="remove"/><trace_log remove="remove"/><metric_log
remove="remove"/><asynchronous_metric_log
remove="remove"/><session_log remove="remove"/><part_log
remove="remove"/></clickhouse>
ulimits:
nofile:
soft: 262144
hard: 262144
And hit Save.
Configure custom domain for self-hosted Plausible
Before deploying this application we need to configure custom domain.
In my case I am using Cloudflare as a DNS and I'll configure subdomain plausible.corpcodingo.com
for Plausible analytics.
Now I need to update Coolify resource with this new domain.
After modifications hit Deploy.
It'll take 2-3 minutes and it should be deployed. You'll need to manually reload page to see a fresh status.
Registering on a self-hosted Plausible
You should visit custom url you specified and create Plausible account there.
On the next step it'll ask you which domain you want to track.
Adding sites to track with Plausible
One thing I noticed with Plausible is that it's able only to track exact domain. I am not able to add root domain and track all of its subdomains.
After inputing domain to track Plausible will display JavaScript snippet.
This code should be pasted in the head section of the site.
Plausible and WordPress
Plausible posses official WordPress plugin. You just need to search for Plausible
inside Add new plugin page on WordPress.
Click the Install Now button and after it's installed click Activate.
Go into Settings -> Plausible Analytics and open Self-Hosted tab.
There you have an input for the custom domain you created earlier.
Click Save Changes and after few reloads your self hosted Plausible should get events from the WordPress site.
Final thought about Plausible
This Plausible installation may seem like very simple and limited but metrics I receive everyday from it are very valuable.
When you take into account that GA4 is only tracking small portion of users without adblockers, you'll understand that you will get a better picture with Plausible analytics.
Better analytics will guide you to create better content and gain higher positions in Google results. This will lead to more sales.
Happy tracking!