root layout <head> (web) or any backend handler (server) · open source (MIT) · ask in plain English

Add analytics to a Railway app Railway.

smolanalytics works two ways for apps hosted on Railway. If Railway serves a web frontend, add two script tags to your root layout head for full autocapture. If you're tracking a backend service, there's no SDK, you POST JSON to /v1/events with a bearer key. Both feed one deterministic, self-hostable analytics instance.

root layout <head> (web) or any backend handler (server)
# Backend service on Railway: POST events, no SDK needed
curl -X POST https://YOUR-INSTANCE/v1/events \
  -H "Authorization: Bearer WRITE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"order_created","distinct_id":"user_123","properties":{"value":49}}'

For a web app on Railway, use the two script tags in your root head instead. Batch backend events into one POST to save calls.

how do I add analytics to railway?

smolanalytics works two ways for apps hosted on Railway. If Railway serves a web frontend, add two script tags to your root layout head for full autocapture. If you're tracking a backend service, there's no SDK, you POST JSON to /v1/events with a bearer key. Both feed one deterministic, self-hostable analytics instance.

Railway commonly runs full-stack or backend services, so the right method depends on what you're measuring. For server-side events like signups, jobs completed, or webhooks received, skip the browser SDK entirely and POST to /v1/events with an Authorization bearer key, one JSON body per event with name, distinct_id and properties. Batch them when you can.

If Railway is serving your web frontend, the two script tags in your root layout head give you autocapture for pageviews, clicks and errors, and you can identify(userId) on login to tie browser sessions to your backend events under one distinct_id. Everything lands in a single open-source instance you self-host free or run hosted from $29/mo, and you ask it questions in plain English with answers computed, not hallucinated.

Honest pricing: 14-day full trial, no credit card. Then Solo $29/mo, never metered on seats or sites. Overage is $5/million with an emailed receipt, the dashboard never locks, and self-hosting the single Go binary is free forever (MIT).

Add analytics to Railway tonight.

One snippet, or one endpoint. Tomorrow morning the verdict tells you which part of the funnel to fix.

questions

How do I add analytics to Railway?
smolanalytics works two ways for apps hosted on Railway. If Railway serves a web frontend, add two script tags to your root layout head for full autocapture. If you're tracking a backend service, there's no SDK, you POST JSON to /v1/events with a bearer key. Both feed one deterministic, self-hostable analytics instance.
Do I need a cookie banner?
Not in cookieless mode. smolanalytics can run without storing anything on the device, so there is no consent banner to add. You still get visitors, referrers, funnels, retention, and paths, and AI-assistant referrals (chatgpt.com, claude.ai, perplexity.ai) show up as their own channel.
Is it enough for a real product, or just page counts?
It does funnels, retention, paths, cohorts, and a daily verdict on what to fix, from the same events, and you ask it in plain English. It deliberately skips session replay, feature flags, and experiments. If you want a straight answer on what to fix, that you own and can self-host free, it fits.

keep reading