---
title: "Deploy OpenPanel Astro"
description: "Product analytics for Astro sites on your own server"
category: "Analytics"
url: https://railway.com/deploy/deploy-openpanel-for-astro-sites
---

# Deploy OpenPanel Astro

Product analytics for Astro sites on your own server

**[Deploy OpenPanel Astro on Railway](https://railway.com/template/deploy-openpanel-for-astro-sites)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/deploy-openpanel-for-astro-sites/manifest.json

- **Creator:** onepush
- **Category:** Analytics

## Template content

### op-dashboard

- **Image:** lindesvard/openpanel-dashboard:2.3.0@sha256:b773cf864454a0ec89b2a133b48bf06202880ed650a75cc2f1f5c87aaed1cffa
- **Health check:** /api/healthcheck

### op-postgres

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:17

### op-api

- **Image:** lindesvard/openpanel-api:2.3.0@sha256:cee4855cd715a7248c5c49090fe93a28ffc505541de20cb238d8884a6bcb9223
- **Start command:** `sh -c "echo Running migrations...; CI=true pnpm -r run migrate:deploy; exec pnpm start"`
- **Health check:** /healthcheck

### op-worker

- **Image:** lindesvard/openpanel-worker:2.3.0@sha256:b22e247fb6980b820c1a954d0e3d2fe88b3edf40a58aa53329467af239538e80
- **Health check:** /healthcheck

### op-proxy

- **Image:** caddy:2-alpine@sha256:d8542f48d34a9cf4e4c11a478865229840e87e4c96ea3f439101f31a5d35f75f
- **Start command:** `sh -c "echo \"$CADDYFILE\" > /etc/caddy/Caddyfile; echo START_OK PORT=$PORT; cat /etc/caddy/Caddyfile; exec caddy run --config /etc/caddy/Caddyfile --adapter caddyfile"`
- **Public domain:** Yes

### op-redis

- **Image:** redis:8.2.1@sha256:5fa2edb1e408fa8235e6db8fab01d1afaaae96c9403ba67b70feceb8661e8621
- **Start command:** `/bin/sh -c "rm -rf ${RAILWAY_VOLUME_MOUNT_PATH}/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass ${REDIS_PASSWORD} --bind '* -::*' --protected-mode no --port ${PORT:-6379} --save 60 1 --dir ${RAILWAY_VOLUME_MOUNT_PATH}"`

### op-clickhouse

- **Image:** clickhouse/clickhouse-server:25.12@sha256:8a790dd3468db22b1d4e7b18a176f378ff5ff6053b9c48dd4ea1fa71a24c5ba6
- **Start command:** `sh -c 'mkdir -p /etc/clickhouse-server/config.d && printf "%s\n" "<clickhouse><listen_host>::</listen_host><listen_host>0.0.0.0</listen_host><trace_log remove=\"remove\"/><text_log remove=\"remove\"/><metric_log remove=\"remove\"/><asynchronous_metric_log remove=\"remove\"/><processors_profile_log remove=\"remove\"/><query_metric_log remove=\"remove\"/><query_thread_log remove=\"remove\"/><query_views_log remove=\"remove\"/><asynchronous_insert_log remove=\"remove\"/><opentelemetry_span_log remove=\"remove\"/><background_schedule_pool_log remove=\"remove\"/></clickhouse>" > /etc/clickhouse-server/config.d/railway-listen.xml && exec /entrypoint.sh'`

## Documentation

# Deploy and Host self hosted OpenPanel Astro (Self-Hosted Web Analytics for Astro) on Railway

This template deploys a self-hosted OpenPanel stack and connects it to your Astro site through the @openpanel/astro SDK component.

## About Hosting OpenPanel Astro open-source software on Railway (self hosted Self-hosted OpenPanel analytics for Astro sites template)

Running OpenPanel Astro on Railway keeps your visitor data in databases you control, not a third-party SaaS.

## Why Deploy OpenPanel Astro, the Google Analytics alternative on Railway (Railway Free Trial)

Google Analytics is free but closed, and your raw event data lives on Google's side unless you export it through BigQuery.

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 OpenPanel Astro 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.

### Railway vs Other Hosting Providers and VPS for OpenPanel Astro self hosting

Railway deploys all seven OpenPanel services from one template, while a VPS leaves the Docker setup and upkeep to you. The table below shows the difference.

| Provider | What You Get with Railway | What You Get with the Other Provider |
| --- | --- | --- |
| DigitalOcean | Template deploys op-proxy, op-api, op-dashboard, op-worker, Postgres, Redis and ClickHouse with volumes attached. | A Droplet with root access, where you write the Compose file and handle upgrades yourself. |
| AWS | Public domain and private networking without touching VPC or security groups. | Full control, but you build the VPC and storage layout before OpenPanel runs. |
| Hetzner | Public domain already routed to /api for the Astro SDK apiUrl. | Low cost per GB, but you configure the reverse proxy, TLS and backups. |

Railway costs more per month than a bare Hetzner box, but you skip maintaining the stack yourself.

## Common Use Cases for hosted OpenPanel Astro

- **Tracking page views on a content-heavy Astro blog:** Set `trackScreenViews={true}` in your root layout so every article visit is counted without per-page code.
- **Measuring CTA clicks on a marketing site:** Call `window.op('track', 'clicky')` from a button handler, then confirm the event appears in the dashboard.
- **Identifying logged-in users:** Pass `profileId` to `OpenPanelComponent` or use `IdentifyComponent` with an email, so events tie to a real profile.
- **Attaching app_version and environment across deploys:** Use `SetGlobalPropertiesComponent` so every event carries the release and environment values.
- **Keeping visitor data on your own instance:** Pointing `apiUrl` at your Railway domain keeps event data in your own Postgres and ClickHouse services.

## Dependencies for OpenPanel Astro Docker hosted on Railway

This stack runs seven services on Railway, so know what you are deploying before you click anything. Your Astro site only talks to the public proxy, and the rest stays private.

### Deployment Dependencies for Managed OpenPanel Astro Service (Product Analytics)

The template wires up the services, but each has a job. op-proxy is the only public service, on port 8080, built from caddy:2-alpine.

### Implementation Details for OpenPanel Astro (Using OpenPanel official docker image)

Most configuration is generated for you. One public domain means cookies work without a custom cookie domain.

## How does OpenPanel Astro compare against other ways to add privacy-first analytics to Astro sites

### OpenPanel Astro vs Google Analytics (Google Analytics Alternative)

- **Data ownership:** Events land in your own Postgres and ClickHouse on Railway. Raw Google data is only reachable through BigQuery.
- **Cost model:** Self-hosting OpenPanel is free with unlimited events, so Railway is the only bill. Google Analytics is also free and wins if you don't want to run infrastructure.
- **Privacy posture:** OpenPanel supports cookieless tracking. Google Analytics has faced GDPR challenges in parts of the EU.

### OpenPanel Astro vs Plausible (Plausible Alternative)

- **User-level analytics:** OpenPanel Astro lets you identify logged-in users with IdentifyComponent and see their event history. Plausible focuses on aggregate page metrics.
- **Running it:** Both are AGPL-3.0 and both self-host. Plausible is simpler to run, while OpenPanel needs Postgres, ClickHouse, and Redis.
- **Dashboard scope:** Plausible is the better pick if you only want a clean page view counter.

### OpenPanel Astro vs PostHog (PostHog Alternative)

- **Scope:** PostHog is a broader suite with feature flags, session replay, and experiments. OpenPanel Astro concentrates on analytics, so it has no flags or replay.
- **Licensing:** PostHog's core is MIT, while OpenPanel is AGPL-3.0. Pick based on which license fits your project.
- **Self-hosting weight:** PostHog is heavier to self-host, and its hobby self-host deploy is limited. OpenPanel's template still runs seven services, so expect real resource use.

### OpenPanel Astro vs Umami (Umami Alternative)

- **Event depth:** Umami is lightweight and focused on page and event metrics. OpenPanel Astro adds user profiles and funnels on the same custom event calls.
- **Footprint:** Umami is quicker to deploy and easier to keep running on a small server. OpenPanel costs more to run at low volume.
- **Astro integration:** OpenPanel ships an official Astro SDK component you drop into a root layout. For a basic site, Umami's simpler script is the quicker route.

## How to use OpenPanel Astro (the OSS product analytics platform)?

1. Deploy the template on Railway, open the public domain, create the first account and a project, and copy the client ID.
2. In your Astro project run `pnpm install @openpanel/astro`.
3. In your root layout's frontmatter import `OpenPanelComponent`, then place it inside `head` with `clientId` set to your client ID, `apiUrl` set to `https://your-domain/api` and `trackScreenViews={true}`.
4. Optionally import `IdentifyComponent` and `SetGlobalPropertiesComponent` and pass `profileId`, `email` and `properties`.
5. Use `window.op('track', 'clicky')` for custom events.

```astro
---
import { OpenPanelComponent, IdentifyComponent } from '@openpanel/astro';
const user = Astro.locals.user;
---

  
    
    {user &amp;&amp; }
  
  

```

## How to self host OpenPanel Astro on other VPS Services (OpenPanel self hosting guide)

Self hosting OpenPanel on a VPS takes more work than on Railway, but the steps are simple.

### Clone the Repository

Clone the repository and move into the folder. Upstream ships Docker Compose files and a setup script.

```bash
git clone https://github.com/Openpanel-dev/openpanel.git
cd openpanel
```

### Install Dependencies

Confirm Docker and Compose are running. Postgres, ClickHouse, and Redis run as containers, so nothing else goes on the host.

```bash
docker --version
docker compose version
```

### Configure Environment Variables

Copy the example env file and set your public domain. In your Astro layout, set `apiUrl` to `https://your-domain/api`.

```bash
cp .env.example .env
# DASHBOARD_URL=https://your-domain
# API_URL=https://your-domain/api
```

Keep `ALLOW_REGISTRATION=true` until you've created your first account, then turn it off.

### Start the OpenPanel Astro Application

Bring the stack up detached, then check the health endpoint through your proxy.

```bash
docker compose up -d
curl https://your-domain/api/healthcheck
```

Railway handles container builds, public domains, and restarts for you, which is the part you'd otherwise maintain yourself on a VPS.

## Official Pricing of OpenPanel Astro (OpenPanel pricing)

OpenPanel Astro is free and open source under AGPL-3.0, so you only pay for the infrastructure it runs on. Yearly billing gives two months free, with a 30-day free trial.

## OpenPanel Astro cloud vs self hosted comparison (Pricing, features, costs, and more)

Self-hosting OpenPanel for an Astro site trades a monthly bill for an infrastructure bill and some upkeep. The figures below show what running it yourself costs.

### Monthly cost of self hosting OpenPanel Astro on Railway

Running the full stack on Railway means paying for seven services: op-proxy, op-api, op-dashboard, op-worker, Postgres, Redis, and ClickHouse.

### System Requirements for Hosting OpenPanel Astro on a VPS

On a VPS, you need enough memory for ClickHouse, Postgres, and Redis to run alongside the dashboard and API, plus persistent disk for the data volumes.

## Frequently Asked Questions (FAQs)

### Do I need to set trackScreenViews explicitly?

Yes. The default is false, so page views won't track unless you set `trackScreenViews={true}` on `OpenPanelComponent` in your root layout.

### How are page views tracked across view transitions?

The upstream docs don't describe how Astro view transitions are handled.

### How do I send custom events from a button?

Call `window.op('track', 'clicky')` from a click handler, where `clicky` is your event name.

### How do I identify a logged-in user?

Add `IdentifyComponent` from `@openpanel/astro` with a `profileId`, plus `email` and `properties` if you have them.

### Why doesn't my filter option see outside variables?

The `filter` option is serialized as a string, so it can't reach variables outside the function. Keep everything the function needs inside its body.

### Does my self-hosted instance need the default scriptUrl changed?

The default `scriptUrl` is `https://openpanel.dev/op1.js`, and the docs don't say whether self-hosters should override it.


## 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/deploy-openpanel-for-astro-sites
