Esc

    ↑ ↓ to moveEnter to openEsc to close

    Guide

    Self-Hosting Analytics

    How to pick a self-hosted analytics tool and get it running on your own server, with numbers you can trust.

    Self-hosted analytics keeps your visitor data on a server you control, and the privacy-friendly tools do it without cookies. This guide compares the main options and walks through a full install.

    A note first: I make Runlight, one of the 4 tools compared here and the one this guide installs, so keep that in mind as you read.

    Why Self-Host Your Analytics

    The main reason is that the data never leaves your hands.

    When you use a hosted analytics service, every pageview goes to someone else's servers, under their terms and their retention rules. When you self-host, the visits land in a database you own, and you decide how long to keep them.

    The second reason is cost at scale.

    Hosted plans are priced by traffic, so the bill grows as the site does. A self-hosted tool costs whatever the server costs, and a small analytics install can often share a server you're already paying for.

    The third is that it fits how a lot of us already work.

    If you run your own server for the site, adding analytics to it is one more container or one more package, and it's covered by the same backups.

    I wrote about why I've stuck with my own servers in Self-Hosting Renaissance.

    The honest downside is that you become the person who patches it. If an update breaks something at midnight, nobody else is going to notice.

    Self-hosting is cheaper in money and more expensive in attention, and it's worth being clear about that before you start.

    The Self-Hosting Cost Calculator puts a number on the trade if you want to see it for your own setup.

    The Options Compared

    There are plenty of self-hostable analytics tools, and Plausible, Umami, and Matomo are the 3 that come up most often.

    Runlight is much newer, and since it's the one I know best, it's in here too. I've tried to describe each tool from its own site and docs.

    RunlightPlausible CEUmamiMatomo
    LicenseMITAGPLv3MITGPLv3
    Self-hosted priceFreeFreeFreeFree (paid plugins extra)
    Hosted versionNone (yet)From $9 a month (10k pageviews)Free up to 100K events, Pro $20 a monthFrom $26 a month (50,000 hits)
    DatabaseSQLite, Postgres, MySQL, MariaDB (ClickHouse optional on the standalone server)ClickHouse (events) and PostgreSQLPostgreSQLMySQL or MariaDB
    Runs asApp package or standalone server, plus CMS pluginsDocker ComposeDocker Compose or NodePHP app
    CookiesNoneNoneNoneYes by default, can be turned off

    Prices were checked on each project's own pricing page in November 2026, and they change, so look again before you decide.

    Runlight

    Runlight is open source analytics that can run inside your own app as a library, storing its data in your app's database, or as a standalone server you point several sites at.

    It has libraries for JavaScript/TypeScript, PHP, Python, Ruby, Go, Java, .NET, Elixir, and Rust. There are also plugins available for WordPress, Drupal, and Craft CMS.

    The dashboard covers visitors and where they came from, with goals and revenue on top. It also has a channel for visits sent by AI assistants like ChatGPT and Claude. It's MIT licensed and there's no paid tier.

    Plausible Community Edition

    Plausible's self-hosted release is called Community Edition. It's AGPLv3 and runs with Docker Compose. Events are stored in ClickHouse, which needs a CPU with SSE 4.2 or NEON, and at least 2 GB of RAM is recommended.

    Plausible keeps some features on the paid cloud only (funnels and ecommerce revenue goals among them), and Community Edition gets a long-term release twice a year.

    It's polished and widely used, and the cloud version is a good fallback if you decide you'd rather not run it.

    Umami

    Umami is MIT licensed and built on Node, with PostgreSQL (version 12.14 or newer) as its database.

    The quickest route is the Docker Compose file in the repo, which starts Umami and Postgres together once you've set APP_SECRET in a .env file. It's light and doesn't use cookies.

    Umami Cloud has a free tier of 100K events a month for 1 site.

    Matomo

    Matomo is the oldest of the 4 and the most complete, closer to a full Google Analytics replacement. It's a GPLv3 PHP app on MySQL or MariaDB, and its premium plugins are sold separately.

    By default it sets first-party cookies, so if you want to skip a banner you'll need to configure it for that. Matomo publishes a guide for meeting the French regulator's (CNIL) consent exemption, which is useful even outside France.

    How I'd Choose

    • If you want analytics inside an app you already run, with the data in the same database, Runlight is built for exactly that.
    • If you want a separate dashboard for many sites and you're comfortable with ClickHouse, Plausible CE is a solid pick.
    • Umami is a good fit if you already run Postgres and want something small.
    • Matomo makes sense when you need the depth of a full analytics suite and don't mind a heavier install.

    Installing Runlight Step by Step

    Runlight installs in 2 ways. The library route mounts the dashboard at /runlight inside your own app. The standalone server is a single container that any number of sites can send visits to.

    I'll walk through the standalone server here, since it works with any site, and then cover the library briefly.

    What You Need

    • A Linux server with Docker installed.
    • A subdomain for the dashboard, like stats.example.com, with an A record (and AAAA if you use IPv6) pointing at the server, and ports 80 and 443 open.
    • A reverse proxy for HTTPS. I'll use Caddy because it handles certificates on its own.

    1. Start the Container

    Bash/Shell
    docker run -d --name runlight \
      --restart unless-stopped \
      -p 127.0.0.1:3000:3000 \
      -v runlight:/data \
      -e RUNLIGHT_URL=https://stats.example.com \
      ghcr.io/runlightsh/runlight
    

    Binding to 127.0.0.1 keeps port 3000 off the public internet, so the only way in is through the proxy.

    The runlight volume holds the SQLite database and the server's secret, and RUNLIGHT_URL is the public address that invite and report emails link to.

    If you'd rather store data in Postgres or MySQL, add -e DATABASE_URL=postgres://... with your connection string. SQLite is fine for most sites.

    2. Put HTTPS in Front of It

    The server speaks plain HTTP, so the proxy adds HTTPS. With Caddy, the whole config for this is:

    Text
    stats.example.com {
      reverse_proxy localhost:3000
    }
    

    Reload Caddy and it'll fetch a certificate for the subdomain. If you use nginx instead, a proxy_pass http://127.0.0.1:3000; block works too, with a certificate from certbot or similar, as long as it also sets proxy_set_header Host $host;, proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;, and proxy_set_header X-Forwarded-Proto $scheme;. Without the forwarded address, every visitor looks like the same person.

    3. Create Your Account

    On its first start, the server writes a one-time setup link to its logs:

    Bash/Shell
    docker logs runlight
    

    The link starts with http://localhost:3000, so keep everything from /setup onward and put your public address in front, so it looks like https://stats.example.com/setup?code=....

    Then enter your email and a password of at least 10 characters. The link only works while there's no account yet, and each restart makes a new code, so use the newest one.

    4. Add Your Site

    After you sign in, the dashboard asks for your first site's domain and then shows its script tag, which looks like this:

    HTML
    <script defer src="https://stats.example.com/s.js?site=example.com" data-site="example.com"></script>
    

    Put it on every page, just before </head>. Add more sites from the menu beside the site name.

    If your site has a Content-Security-Policy, add the stats subdomain to script-src and connect-src, or the browser will block the script quietly. My CSP guide covers both directives.

    5. Leave Yourself Out

    Your own visits skew the numbers on a small site.

    Open any page of your site with ?runlight=ignore on the end, in each browser you use, and that browser is excluded for a year. ?runlight=track turns it back on. The flag belongs to one domain, so if your site answers on both www and the bare domain, open each one.

    This opt-out flag is the only thing Runlight's script ever stores in a browser.

    6. Set Up Reports (Optional)

    The server runs its own scheduled check every 5 minutes, so there's no cron job to add.

    To get weekly or monthly email reports, add a mail service under Settings, then Email service, and add recipients under Settings, then Email reports.

    7. Back It Up and Keep It Updated

    Back up the data folder, which in Docker is the runlight volume. It holds the database and the secret file, and without the secret everyone has to sign in again and two-factor sign-in has to be set up again.

    The simplest safe copy stops the container for a few seconds so the database isn't being written mid-copy:

    Bash/Shell
    docker stop runlight
    docker run --rm -v runlight:/data -v /root/backups:/backup alpine \
      tar czf /backup/runlight-$(date +%F).tar.gz -C /data .
    docker start runlight
    

    To upgrade, pull the new image and recreate the container with the same volume. The database updates itself when it starts:

    Bash/Shell
    docker pull ghcr.io/runlightsh/runlight
    docker stop runlight && docker rm runlight
    # then run the same docker run command from step 1
    

    The Library Route

    If your site is an app you control, the library keeps everything in one place. In PHP, for example:

    Bash/Shell
    composer require runlight/runlight
    

    You create a runlight.php file that returns a configured instance with a database store and your site's name, hostnames, and timezone, then route /runlight and /go/ to it from your front controller. The script tag becomes a local one:

    HTML
    <script defer src="/runlight/s.js"></script>
    

    Set RUNLIGHT_TOKEN to a long random string, then open /runlight/?token= followed by it once to sign in. The library also needs its scheduled check called on a timer.

    The Runlight docs have the exact files for each framework, from Laravel and Next.js to Rails and Phoenix.

    Whether you need a consent banner depends on more than cookies.

    The EU's ePrivacy rules cover storing information on a visitor's device and reading information from it, and the European Data Protection Board's guidelines say a script that tells the browser to send data back can count as reading from the device.

    So "no cookies" helps a lot, but it doesn't settle the question on its own.

    What usually settles it is a consent exemption.

    France's regulator, the CNIL, exempts audience measurement from consent when it's used only for the site's own statistics and isn't combined with other data, among other conditions that include telling visitors and letting them opt out.

    The UK added a similar exemption for first-party statistics in February 2026. Other EU regulators are stricter or vaguer, and the rules may differ where your visitors are.

    Runlight's design keeps it close to those conditions. It sets no cookies and stores nothing in the visitor's browser.

    IP addresses and user agents are used to make a daily visitor hash and then dropped, and the salt behind that hash is replaced every day, so nobody can be followed from one day to the next.

    Plausible and Umami take similar cookie-free approaches. Matomo can, once you configure it.

    None of this is legal advice, and I'd still do these things whatever tool you pick:

    • Say in your privacy policy which analytics you use and what it collects.
    • Give people a way to opt out, or honor Do Not Track (Runlight supports it with a data-dnt attribute on the script tag), though few browsers still send it.
    • If your audience is mostly in one country, read that regulator's guidance on analytics.
    The tool can only be as private as what you send it. If your page paths, titles, or event properties contain email addresses, those get stored too.

    That last point catches people out. Runlight keeps page paths, titles, and event properties as you send them, and every tool here works the same way, so keep personal details out of URLs and events.

    Checking the Data

    Once the script is in, check that visits actually arrive before you trust any of it.

    The launch-day version of this is on my product launch checklist, and here's the longer version:

    1. Open your site in a private window (so the ignore flag doesn't apply) and watch the dashboard's live view. In Runlight you should see yourself under "here now" within seconds.
    2. If nothing shows up, open the browser's developer tools and check the Network tab for the script and the request it sends. A blocked request usually means a CSP rule. An ad blocker on your own browser can do it too. If the request goes out and still nothing shows up, check that the data-site value matches the site's domain in Runlight.
    3. Click through a few pages and check that each one appears, with the right title. Single-page apps are the usual problem here. Runlight follows pushState navigation on its own, and hash-based routers need a data-hash attribute.
    4. Send a test event if you use goals, then look for it in the dashboard:
    Js
    runlight("Newsletter signup", { source: "footer" });
    
    1. After a week, compare the visitor count with your server logs or your old tool. They won't match. Logs count bots and everyone who blocks scripts, so they'll come out higher than any script-based tool. Cookie-based tools count a returning visitor once across many days, while Runlight counts each visitor once per day, so over a week Runlight will usually show more visitors than a cookie-based tool. Some gap is normal, and it can be large on a technical audience. What you're checking for is a trend that moves the same way.

    If all 5 look right, you can start reading the numbers instead of doubting them, which is the point of having analytics in the first place.

    Also by me

    Runlight

    This guide sets Runlight up as its own server. I built it to install like a package inside the app you already run too, so your analytics live in the same database as everything else and there's no separate server to look after.

    Visit runlight.sh