---
title: "Deploy GoatCounter"
description: "GoatCounter is an open source, privacy-friendly, web analytics platform"
category: "Analytics"
url: https://railway.com/deploy/39H_-2
---

# Deploy GoatCounter

GoatCounter is an open source, privacy-friendly, web analytics platform

**[Deploy GoatCounter on Railway](https://railway.com/template/39H_-2)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/39H_-2/manifest.json

- **Creator:** Ntokozo's Projects
- **Category:** Analytics
- **Total deploys:** 16

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

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

### goatcounter

- **Source:** https://github.com/arp242/goatcounter
- **Start command:** `./goatcounter db create site -vhost ${HOST_DOMAIN} -user.email ${SITE_USER_EMAIL} -user.password ${SITE_USER_PASSWORD} -db ${DATABASE} -createdb && ./goatcounter serve -db ${DATABASE} -listen 0.0.0.0:${PORT} -tls http`
- **Public domain:** Yes

## Documentation

## Overview
GoatCounter is an [open source](https://github.com/arp242/goatcounter) web analytics platform available as a free donation-supported hosted service or self-hosted app. It aims to offer easy to use and meaningful privacy-friendly web analytics as an alternative to Google Analytics or Matomo. More about [why it was made here](https://www.goatcounter.com/why).

## Configuration
There are two environment variables that require manual updates (the default values for the rest are sufficient):

```
SITE_USER_EMAIL=admin@email.com
SITE_USER_PASSWORD=password
```

The site user email and password are both required to setup the goatcounter inital user. The email used need not exist, it will simply be used as the username for the goatcounter user - no activation email will be sent for this user. Additional users can be added in-app after signing in as this initial user.

## Deploy
###  Service
In order to successfully build and deploy the service, the `Build Command` and `Start Command` in the services' `General` settings need to be updated.
The value for the `Build Command` should be set to:

```bash
go build ./cmd/goatcounter
```

The value for the `Start Command` should be set to:

```bash
./goatcounter db create site -vhost ${HOST_DOMAIN} -user.email ${SITE_USER_EMAIL} -user.password ${SITE_USER_PASSWORD} -db ${DATABASE} -createdb &amp;&amp; ./goatcounter serve -db ${DATABASE} -listen 0.0.0.0:${PORT} -tls http
```

**Note**: The `Start Command` above is only valid for the first time the service is deployed - it will create the database entries for the site and initial user.
After the service has successfully deployed for the first time. This `Start Command` will need to be updated to remove the `./goatcounter db create site` command.
So for subsequent deploys to be successful, it should be updated ot the following:

```bash
./goatcounter serve -db ${DATABASE} -listen 0.0.0.0:${PORT} -tls http
```

Failing to do so will result in the following deployment error:

```
goatcounter: there is already a site for the host ""
```

### Website
Sending metrics to your new goatcounter requires adding a `

## Similar templates

- [Typesense Multilingual](https://railway.com/deploy/deploy-typesense-multilingual-search) — Locale-aware multilingual search with Typesense
- [Formbricks | Open-Source Typeform & Qualtrics Alternative](https://railway.com/deploy/formbricks-surveys) — Surveys, NPS and in-app feedback on your own Postgres, Hub and Cube
- [Typesense PHP](https://railway.com/deploy/typesense-php) — official PHP client against Railway

Open this page in a browser: https://railway.com/deploy/39H_-2
