---
title: "Deploy Open Analytics | (Just Updated) Google Analytics Alternative, Admin Login Generated, Sign-up Closed"
description: "Open Analytics self-hosted web analytics, Google Analytics alternative"
category: "Analytics"
url: https://railway.com/deploy/open-analytics-or-just-updated-google-an
---

# Deploy Open Analytics | (Just Updated) Google Analytics Alternative, Admin Login Generated, Sign-up Closed

Open Analytics self-hosted web analytics, Google Analytics alternative

**[Deploy Open Analytics | (Just Updated) Google Analytics Alternative, Admin Login Generated, Sign-up Closed on Railway](https://railway.com/template/open-analytics-or-just-updated-google-an)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/open-analytics-or-just-updated-google-an/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** Analytics

## Template content

### valkeyq

- **Image:** ghcr.io/bon5co/openanalytics-railway-valkey-queue:latest@sha256:3dd36b327f9efa200715dd774b06d9e78bfa3667e6de40bba212dd61b65f0eb7

### postgres

- **Image:** postgres:17.10-alpine

### api

- **Image:** ghcr.io/bon5co/openanalytics-railway-api:latest@sha256:e72d1bc501956684b053e538359f19a43f27c2df8ffd3b0d96321a97ead7e80a
- **Health check:** /health
- **Public domain:** Yes

### collector

- **Image:** ghcr.io/bon5co/openanalytics-railway-collector:latest@sha256:fee76d9b7365d6747bd8f1aa7bd464f0b1fce9e0c64e2d72beeff0d5c6737858
- **Health check:** /health
- **Public domain:** Yes

### valkeyr

- **Image:** ghcr.io/bon5co/openanalytics-railway-valkey-realtime:latest@sha256:f65fc443035e8f57f4e88a23dcf3293311a8cb01856a07423754eb58d2481d0c

### worker

- **Image:** ghcr.io/bon5co/openanalytics-railway-worker:latest@sha256:7109be697ccaed69d419b70ec51e24ba19b1bf866bf49d0b6f7ea36b63a02f10

### migrate

- **Image:** ghcr.io/bon5co/openanalytics-railway-migrate:latest@sha256:0d1473a3581d4833dc97a44305386e54b3bca32ee0aaeef82c52b322e4c39b75

### realtime

- **Image:** ghcr.io/bon5co/openanalytics-railway-realtime:latest@sha256:8f258a1b16ad929fbe20bcc105dccadbba9c6e4d1c65414b7d5c41fca9eabc2f
- **Health check:** /health
- **Public domain:** Yes

### gateway

- **Image:** ghcr.io/bon5co/openanalytics-railway-gateway:latest@sha256:166c6010713c9ce830eab386a9f52582583ad230f5f7160063cd43ab763866ca

### clickhouse

- **Image:** ghcr.io/bon5co/openanalytics-railway-clickhouse:latest@sha256:9907d740c06fa0427d608964f2b8d14066702e1488bca04ca13de30ab713cc8f

### web

- **Image:** ghcr.io/bon5co/openanalytics-railway-web:latest@sha256:668f1d803019e0eae7e82ade03218f289b560bbc36531cfe8492b48f1df5d492
- **Health check:** /login
- **Public domain:** Yes

## Documentation

# Deploy and Host Open Analytics on Railway

**Built for an LLM agent to deploy and use.** The deploy form has no fields to fill: the admin login is generated, public sign-up is closed from the first request, and every database lives on a volume. Open Analytics is open-source, privacy-friendly web analytics, a self-hosted Google Analytics alternative with pageviews, sessions, custom events, conversions, web vitals, a live realtime view and a REST API.

## About Hosting Open Analytics

This template runs eleven services. Four are public: **web** (the dashboard), **api** (the REST and sign-in API), **collector** (event ingest, the address a tracked page sends to) and **realtime** (the live feed). Seven are private: **gateway** (the query gateway), **worker** (sessionizing and rollups), **migrate** (the one-shot schema job), **postgres** (accounts, sites and settings, on a volume at `/var/lib/postgresql`), **clickhouse** (events, on a volume at `/var/lib/clickhouse`), **valkeyq** (the durable queue, on a volume at `/data`) and **valkeyr** (the realtime cache, on a volume at `/data`). The Open Analytics v0.8.0 images are pinned by digest, and so are the wrappers.

**What the wrappers fix.** Upstream signs its internal tokens and encrypts its credentials with keys you are expected to generate and distribute by hand, and has no variable that creates the first admin. The wrappers derive each signing key from a per-purpose generated seed (`OA_QUERY_SEED`, `OA_REALTIME_SEED`, `OA_KEYRING_SEED`), wait for the schema job before starting, create the admin from `ADMIN_EMAIL` and `ADMIN_PASSWORD` before the API listens, and run nginx in front of the public node services so the client address is the first `X-Forwarded-For` hop. Sign-up is closed: `POST /api/auth/sign-up/email` answers 403.

Measured on a Railway control deploy of this template: a sign-up from outside answers 403, a write without a session answers 401, the generated admin signs in, a wrong password answers 401, a site is created, a pageview sent to the collector is accepted with 202 and the overview read on the API shows it.

**Using it.** Open the `web` domain and sign in with `ADMIN_EMAIL` and `ADMIN_PASSWORD` from the `api` service variables. `ADMIN_EMAIL` is `admin@` followed by the web domain. Create a site, then put the tracking snippet it shows on your pages; it sends to the `collector` domain. An agent can do the same through the API below. Redeploys keep the same login, because the admin is only created when the database has no user, and the data is on the volumes.

### Agent contract

- Public URL: `https://WEB_PUBLIC_DOMAIN` (dashboard, the `web` service), `https://API_PUBLIC_DOMAIN` (REST and sign-in, the `api` service), `https://COLLECTOR_PUBLIC_DOMAIN` (ingest, the `collector` service); each is the `RAILWAY_PUBLIC_DOMAIN` of that service
- Private URL: `http://api.railway.internal:8080` and `http://collector.railway.internal:8080`
- Credentials: the variables `ADMIN_EMAIL` and `ADMIN_PASSWORD` on the `api` service are the admin login, given as plain text
- Auth: `POST /api/auth/sign-in/email` on the api domain with a JSON body `{"email":"...","password":"..."}` and an `Origin` header equal to the web URL returns a session cookie; send the cookie and the same `Origin` on every call. Without it a read or write answers 401. Sign-up is closed (`POST /api/auth/sign-up/email` answers 403). Event ingest, `POST /v1/events` on the collector, is public by design, because a tracked page sends it, and is keyed by the site's public tracking token.
- Health: `GET /health` on the api domain returns 200 without credentials

```bash
#!/bin/sh
# needs: WEB_PUBLIC_DOMAIN, API_PUBLIC_DOMAIN, COLLECTOR_PUBLIC_DOMAIN (RAILWAY_PUBLIC_DOMAIN of the web, api and collector services), ADMIN_EMAIL and ADMIN_PASSWORD (variables of the api service); also curl, sed, od and GNU date.
W="https://$WEB_PUBLIC_DOMAIN"; A="https://$API_PUBLIC_DOMAIN"; K="https://$COLLECTOR_PUBLIC_DOMAIN"
J="Content-Type: application/json"
O="Origin: $W"
C=$(mktemp)
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' "$A/health")" = 200 ]; do n=$((n+1)); [ "$n" -le 90 ] || break; sleep 5; done
curl -s -o /dev/null -w "health: %{http_code}\n" "$A/health"
# sign-up is closed: a stranger cannot create an account
curl -s -X POST -H "$J" -H "$O" -d '{"email":"stranger@example.com","password":"stranger-password-1","name":"stranger"}' "$A/api/auth/sign-up/email" -o /dev/null -w "public signup: %{http_code}\n"
# a stranger cannot read or write analytics data: no session and a wrong password are both refused
curl -s -o /dev/null -w "read without key: %{http_code}\n" -H "$O" "$A/v1/sites"
curl -s -X POST -H "$J" -H "$O" -d '{"slug":"stranger","name":"stranger"}' "$A/v1/sites" -o /dev/null -w "write without key: %{http_code}\n"
curl -s -X POST -H "$J" -H "$O" -d "{\"email\":\"$ADMIN_EMAIL\",\"password\":\"not-the-admin-password\"}" "$A/api/auth/sign-in/email" -o /dev/null -w "login with wrong password: %{http_code}\n"
# the generated admin signs in and receives a session cookie
CODE=$(curl -s -c "$C" -X POST -H "$J" -H "$O" -d "{\"email\":\"$ADMIN_EMAIL\",\"password\":\"$ADMIN_PASSWORD\"}" "$A/api/auth/sign-in/email" -o /dev/null -w '%{http_code}')
if [ "$CODE" = 200 ]; then echo "login with key: ok"; else echo "login with key: FAILED $CODE"; fi
curl -s -b "$C" -H "$O" "$A/v1/sites" -o /dev/null -w "read with key: %{http_code}\n"
# with the session: create a site, the response carries its tracking token
SLUG="agent-$(date +%s)"
curl -s -b "$C" -X POST -H "$J" -H "$O" -d "{\"slug\":\"$SLUG\",\"name\":\"agent\"}" "$A/v1/sites" -o site.json
SITE=$(sed -n 's/^{"site_id":"\([^"]*\)".*/\1/p' site.json)
TK=$(sed -n 's/.*"public_token":"\([^"]*\)".*/\1/p' site.json)
if [ -n "$SITE" -a -n "$TK" ]; then echo "write with key: ok"; else echo "write with key: FAILED"; fi
# ingest is public by design (a tracked page sends it): one pageview with a browser-like request and a lowercase UUIDv7 event_id
NOW=$(date -u +%Y-%m-%dT%H:%M:%S.000Z)
HEX=$(printf '%012x' "$(date +%s%3N)")
RND=$(od -An -N10 -tx1 /dev/urandom | tr -d ' \n')
EID="$(echo $HEX | cut -c1-8)-$(echo $HEX | cut -c9-12)-7$(echo $RND | cut -c1-3)-8$(echo $RND | cut -c4-6)-$(echo $RND | cut -c7-18)"
UA='Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36'
curl -s -X POST -A "$UA" -H "$J" -H 'Accept: */*' -H 'Accept-Language: en-US,en;q=0.9' -H 'Origin: https://example.com' -d "{\"schema_version\":1,\"tracking_key\":\"$TK\",\"sent_at\":\"$NOW\",\"context\":{\"sdk\":\"web\",\"sdk_version\":\"1.0.0\"},\"events\":[{\"event_id\":\"$EID\",\"type\":\"page_view\",\"occurred_at\":\"$NOW\",\"page\":{\"url\":\"https://example.com/hello\",\"title\":\"Hello\"}}]}" "$K/v1/events" -o /dev/null -w "ingest: %{http_code}\n"
# the pageview becomes queryable after the worker has rolled it up
FROM=$(date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%S.000Z); TO=$(date -u -d '1 hour' +%Y-%m-%dT%H:%M:%S.000Z)
ov() { curl -s -G -b "$C" -H "$O" --data-urlencode "from=$FROM" --data-urlencode "to=$TO" --data-urlencode "timezone=UTC" "$A/v1/sites/$SITE/analytics/overview"; }
n=0; until ov | grep -q '"pageviews":[1-9]'; do n=$((n+1)); [ "$n" -le 24 ] || break; sleep 5; done
if ov | grep -q '"pageviews":[1-9]'; then echo "data stored: ok"; else echo "data stored: FAILED"; fi
```

Expected output against a fresh deploy:

```text
health: 200
public signup: 403
read without key: 401
write without key: 401
login with wrong password: 401
login with key: ok
read with key: 200
write with key: ok
ingest: 202
data stored: ok
```

The refusals are the contract: `public signup: 403`, `write without key: 401` and `login with wrong password: 401`. The snippet creates one site named `agent` with a fresh slug on every run and writes `site.json` in the current directory.

## Why Deploy Open Analytics on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Open Analytics on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

- **Agent-ready** - no deployer fields, a contract block, and one script that proves health, closed sign-up, refused strangers, a signed-in write, ingest and stored data.
- **Locked from the first request** - the admin is created before the API listens and public sign-up is off, so nobody can claim the instance before you do.
- **Keys generated for you** - the signing and encryption keys are derived from generated seeds, nothing to distribute by hand.
- **Data survives redeploys** - Postgres, ClickHouse and both Valkey instances each have a volume.
- **Pinned** - the Open Analytics images are pinned by digest, and so are the wrappers.

## Common Use Cases

- **Privacy-friendly website analytics** - pageviews, sessions and referrers without a consent banner.
- **Product analytics for an app** - custom events, conversions and web vitals on infrastructure you own.
- **A Google Analytics alternative for a client site** - one login, one tracking snippet, and the data stays in your project.

## Dependencies for Open Analytics Hosting

- The eleven services and four volumes created by the template. Nothing external is required.
- Open Analytics is licensed AGPL-3.0; the wrappers change no upstream source. No IP geolocation database is bundled, so country and city fields stay empty unless you add one.

### Deployment Dependencies

- [Open Analytics repository](https://github.com/OpenLabs-so/openanalytics)
- [Wrapper image source](https://github.com/bon5co/openanalytics-railway)


## Similar templates

- [Plausible WordPress](https://railway.com/deploy/deploy-plausible-for-wordpress-sites) — Cookie-free WordPress stats from your own Plausible
- [Typesense Multilingual](https://railway.com/deploy/deploy-typesense-multilingual-search) — Locale-aware multilingual search with Typesense
- [Formbricks](https://railway.com/deploy/formbricks-surveys) — Surveys, NPS and in-app feedback on your own Postgres, Hub and Cube

Open this page in a browser: https://railway.com/deploy/open-analytics-or-just-updated-google-an
