Railway

Deploy traffic-source

Self-hosted analytics with Stripe tracking & affiliates.

Deploy traffic-source

Just deployed

/data/analytics.db

Traffic Source

Open-source, self-hosted web analytics with Stripe conversion tracking and affiliate management. No monthly fees. No data sharing. Own your data forever.

Traffic Source Dashboard

What You Get

  • Real-time Analytics — Live visitor count, pageviews, sessions, bounce rate, and session duration
  • Traffic Sources — Referrers and full UTM parameter tracking (source, medium, campaign, term, content)
  • Geo Tracking — Country and city-level data via Cloudflare proxy headers
  • Conversion Tracking — Stripe integration that auto-syncs payments every 60 seconds — no webhooks needed
  • Affiliate System — Custom commission rates, referral links, and public affiliate dashboards
  • Visitor Journeys — Full session replay showing every page visited before converting
  • Multi-site — Track multiple websites from one dashboard
  • Lightweight Script — ~3KB tracking snippet with SPA support
  • Privacy-first — No cookies, all data stays on your server
  • SQLite — Zero-config database, no external services needed

Deploy and Host

Deploy Traffic Source on Railway with one click. Railway handles builds, SSL, and domain provisioning automatically — no server configuration needed.

About Hosting

Traffic Source runs as a single Next.js service on Railway. Your analytics data is stored in a SQLite database file on a persistent Railway Volume — no external database required. Railway auto-provisions a public HTTPS domain and injects it into your environment on deploy.

Make sure the Volume is mounted to ./data so your database survives redeployments.

Why Deploy

  • No monthly SaaS fees — Pay only for Railway usage (~$5/mo for low-traffic)
  • Full data ownership — All analytics stay on your Railway instance
  • One-click setup — No Nginx, PM2, or VPS configuration required
  • Auto-scaling — Railway handles traffic spikes without manual intervention
  • Built-in SSL — HTTPS domain provisioned automatically on deploy

Common Use Cases

  • Indie hackers and solo founders who want analytics without paying $20+/mo for Plausible or Fathom
  • SaaS products that need Stripe conversion tracking tied to visitor sessions
  • Products with affiliate programs needing referral link tracking and commission dashboards
  • Developers who want full ownership of their analytics data without relying on third-party services
  • Multi-product portfolios that need to track multiple sites from a single dashboard

Dependencies for Traffic Source

Deployment Dependencies

  • Node.js 20+ — Included automatically via Railway's Nixpacks builder
  • SQLite (better-sqlite3) — Bundled, no external database needed
  • Railway Volume — Mount to ./data for persistent database storage
  • Stripe API Key (optional) — Required only if you want conversion tracking

After Deploying

1. Add the tracking script to your website's ``:

2. First login — Visit your deployed URL and register. Only the first user can register; after that registration is locked.

3. Stripe conversion tracking (optional) — Add your Stripe Secret Key in site Settings, then pass visitor IDs in your checkout:

metadata: {
  ts_visitor_id: window.__ts.vid,
  ts_session_id: window.__ts.sid(),
}

4. Affiliate tracking — Create affiliates in the dashboard and share their referral link: https://your-site.com?ref=affiliate-slug

Environment Variables

VariableDescription
JWT_SECRETAuto-generated 64-char secret on deploy
JWT_EXPIRYToken expiry, default 7d
NEXT_PUBLIC_APP_URLAuto-set to your Railway domain
DATABASE_PATHPath to SQLite file, default ./data/analytics.db

Links


Template Content

More templates in this category

View Template
Bugsink
Self-hosted Error Tracking. Sentry-SDK compatible

zǝʇɹoɔ oɓıɹpoɹ
View Template
SubTrackr
Self-hosted Subscription Tracker

amnesia
View Template
Dashy — Open Source Homer & Homarr Alternative on Railway
Self Host Dashy. Open Source Start Page with Widgets & Themes

Heimdall