Railway — Manual Setup

Add JustAnalytics to a Railway-deployed service by setting environment variables and initialising the Node SDK.

Railway — Manual Setup

JustAnalytics works on any Railway-deployed service. This page describes the manual setup that works today.

A Railway template / one-click installer is on the roadmap — see Future Work below.

Time to data: 3 minutes

Prerequisites#

  • A JustAnalytics account with at least one site
  • A Railway project with at least one service (any runtime — Node, Python, Go, Ruby, etc.)

Step 1 — Add environment variables on Railway#

In your Railway service: Variables → New Variable. Add the following, sourced from your JustAnalytics dashboard's API Keys page:

JUSTANALYTICS_SITE_ID=cmkc0xbe70001fdge4feizme8
JUSTANALYTICS_API_KEY=ja_prod_XXXXXXXXXXXX

Railway exposes the deploy commit hash automatically as RAILWAY_GIT_COMMIT_SHA — useful for release tracking in the next step.

Step 2 — Initialise the SDK for your runtime#

Pick the SDK for the language your service runs. The pattern is the same: read the env vars at startup, hand them to init(). See the dedicated Node, Python, Go, Ruby, or other SDK docs for full setup.

Example for a Node.js Express service on Railway:

// In your app's entrypoint, BEFORE importing express
import JA from '@justanalyticsapp/node';

JA.init({
  apiKey: process.env.JUSTANALYTICS_API_KEY,
  serviceName: process.env.RAILWAY_SERVICE_NAME ?? 'my-railway-service',
  environment: process.env.RAILWAY_ENVIRONMENT ?? 'production',
  release: process.env.RAILWAY_GIT_COMMIT_SHA,
});

import express from 'express';
const app = express();
// HTTP, DB, fetch — all auto-traced from here on

Railway exposes several useful build-time variables you can pass through:

RAILWAY_SERVICE_NAME       — name of the service in the Railway UI
RAILWAY_ENVIRONMENT        — environment name (production, staging, etc.)
RAILWAY_GIT_COMMIT_SHA     — commit hash of the deployed code
RAILWAY_GIT_BRANCH         — branch name
RAILWAY_DEPLOYMENT_ID      — unique ID per deploy

Step 3 — (Optional) Add the frontend script if you serve HTML#

If the Railway service also serves a frontend (SSR app, traditional MVC, etc.), add the tracker to your root template's <head>:

<script
  defer
  src="https://justanalytics.app/tracker.js"
  data-site-id="cmkc0xbe70001fdge4feizme8">
</script>

For services that only expose an API (no HTML output), skip this step — the SDK on Step 2 is enough.

Verification#

Hit your Railway service from the browser or curl and watch the JustAnalytics dashboard — the request should appear as a trace within seconds.


Future Work#

A one-click Railway template will be published to the Railway Templates Gallery. When live, it will:

  • Pre-fill JUSTANALYTICS_SITE_ID, JUSTANALYTICS_API_KEY, and JUSTANALYTICS_ENDPOINT on the service via a guided flow
  • Wire the deploy webhook so every Railway deploy becomes a release event in JustAnalytics
  • Surface RAILWAY_DEPLOYMENT_ID and RAILWAY_GIT_COMMIT_SHA automatically on every error and trace

Until then, the manual setup above gives you the full telemetry — you wire the env vars yourself.