# Self-hosted product analytics on one Go binary

Self-hosted product analytics on one Go binary with Postgres, ClickHouse, NATS, and Dragonfly. Every feature, every event on your own servers, AGPL-3.0 and free.

Source: https://pug.sh/self-hosted-analytics

Run Pug on your own servers and every event stays in your infrastructure. It is the same build as Pug Cloud, under AGPL-3.0, with no license fee and no event limit.

- [Self-hosting guide](https://docs.pug.sh/self-hosting)
- [View source](https://github.com/pug-sh/pug)

## Why teams run analytics themselves

### Events stay on your servers

Events are written to your own ClickHouse and never sent to a third party.

### Your region, your access rules

You choose where the servers run and who can reach them, which simplifies GDPR and data-residency requirements.

### Code you can audit

Under AGPL-3.0 you can read every line, check how events are processed, and change what you need.

### No per-event bill

Self-hosting is free. You pay for your own hardware, and nothing per event.

## One binary and four stores

Pug needs four stores you may already run. Host them yourself, or point Pug at managed ones.

SDK: track() and identify()

API: Connect RPC ingest

NATS: Queues every event

Workers: Write events and profiles

ClickHouse: Stores the events

Dashboard: Insights and profiles

- pug: One Go binary: the API server, every worker, migrations, and the CLI
- Dashboard: Static files on any web server
- Dragonfly or Redis 7+: The daily salt, kept off disk
- NATS JetStream: Queues every event
- ClickHouse: Every event
- PostgreSQL 15+: Accounts, boards, and profiles

## What running it takes

### Run it as one process or many.

`pug start` runs the server and every worker in one process, on a small node. In production, each role is its own image, for amd64 and arm64.

[Self-hosting docs](https://docs.pug.sh/self-hosting/)

### Point the SDKs at your server.

Set `endpoint` to its URL in any of the seven SDKs. Leave it out, and events go to Pug Cloud.

[Connect your SDKs](https://docs.pug.sh/self-hosting/connect-sdks/)

### Use SSO on your servers and on Pug Cloud.

Okta, Entra ID, and Google Workspace sign-in work on both, with no SSO tax.

[How SSO works](https://docs.pug.sh/get-started/sso/)

## The full product on your servers

Self-hosted Pug is the build Pug Cloud runs, not a reduced edition. PostHog’s self-hosting docs (checked November 2026) recommend PostHog Cloud for most users, and say self-hosted instances get no support, no guarantees, and none of the paid-plan features.

- Autocapture: page views, clicks, scrolls, form submits, rage and dead clicks
- Seven insight types: Trends, Funnels, Retention, Segmentation, User flow, Top K, and Map
- Unified profiles: identify() merges anonymous activity into one person
- Dashboards with a shared time window, period-over-period comparison, and public links
- The MCP server, at /mcp on your API’s host, so an AI agent can query your data and build dashboards
- AI crawler reports from @pug-sh/crawlers, checked against the IP ranges each operator publishes

* [PostHog’s self-hosting docs](https://posthog.com/docs/self-host)
* [How to set it up](https://pug.sh/guides/self-hosted-analytics-setup)
* [Self-hosted analytics tools, compared](https://pug.sh/learn/best-self-hosted-analytics)
* [How the pipeline works](https://pug.sh/platform)
* [vs Google Analytics](https://pug.sh/compare/google-analytics-alternative)

## What people ask about self-hosting

### What is self-hosted analytics?

Analytics software you run on your own servers, so all visitor and event data stays inside your infrastructure instead of being sent to a third-party cloud. Pug is built to be self-hosted this way under AGPL-3.0.

### What do I need to run Pug?

The pug Go binary, the dashboard’s static files, and four stores: PostgreSQL 15+, ClickHouse, NATS JetStream, and Dragonfly or any Redis 7+. Run the stores yourself or use managed ones. See the setup guide for specifics.

### Is self-hosting free?

Yes. Under AGPL-3.0 there is no license fee, and a self-hosted server has no plans and no event limits. You pay for the servers it runs on.

### Can we sign in with our own identity provider?

Yes. Org admins connect Okta, Microsoft Entra ID, Keycloak or any other OIDC provider from the dashboard, or the operator adds one for the whole server. An identity provider on your internal network works too, and a server that can’t see public DNS verifies domains from the command line.

### Can I move between Pug Cloud and self-hosting?

Both run the same code, and on either one a private key reads every raw event back through the API. There is no built-in migration between the two yet.

### How is this different from Google Analytics?

Google Analytics is free but Google-hosted. Your data lives on their infrastructure. Self-hosted Pug keeps every event on your servers, unsampled, and open source.
