Deploy CAPI Relay | Server-Side Tracking for Facebook & Instagram Ads
Consent-first server-side Conversions API for your Pixel, GDPR-ready
Just deployed
/var/lib/postgresql/data
capi-relay
Just deployed
Deploy and Host CAPI Relay | Server-Side Tracking for Facebook & Instagram Ads on Railway
CAPI Relay is a self-hosted, consent-first relay for the Meta Conversions API. Your website and backend send conversion events to it; it hashes customer data, deduplicates them against your browser Pixel with a shared event ID, and delivers them to Meta with automatic retries. Nothing is sent without consent.
About Hosting CAPI Relay | Server-Side Tracking for Facebook & Instagram Ads
The template deploys two services: the relay (a small Node.js app with a single dependency) and a Postgres database holding a short-lived delivery queue. You paste your dataset (Pixel) ID and a Conversions API access token from Events Manager (no Meta app review needed) and list the websites allowed to send events. Railway generates the dashboard password and the API key for you. Then add a custom domain such as t.yourshop.com so the browser sends the Pixel's first-party cookies to the relay, add the two-line snippet to your site, connect it to your cookie banner, and watch deliveries in the built-in dashboard at /admin.
Common Use Cases
- Recover purchases and leads the browser Pixel misses because of ad blockers, Safari tracking limits or closed tabs
- Send order confirmations and CRM lead updates from your backend straight to Meta with POST /v1/events
- Run server-side tracking for EU/UK websites with consent enforced and short data retention (GDPR)
- Replace a paid hosted tracking gateway with one service you own
Dependencies for CAPI Relay | Server-Side Tracking for Facebook & Instagram Ads Hosting
- A Meta dataset (Pixel) ID and a Conversions API access token, both from Events Manager
- PostgreSQL (included in this template)
- A cookie banner on your website that can run a JavaScript callback when marketing consent is given
Implementation Details
What you get: consent required by default, SHA-256 hashing following Meta's normalization rules, event ID deduplication, a Postgres queue with exponential backoff, automatic isolation of invalid events, 7-day data retention, a dashboard with delivery rate and Meta's error messages, and a test-event button.
Full guide and source code: https://github.com/jean82290/capi-relay. Meta Conversions API documentation: https://developers.facebook.com/docs/marketing-api/conversions-api
Not affiliated with, endorsed or sponsored by Meta Platforms, Inc. You are responsible for collecting valid consent and following Meta's Business Tools Terms.
Why Deploy CAPI Relay | Server-Side Tracking for Facebook & Instagram Ads on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying CAPI Relay | Server-Side Tracking for Facebook & Instagram Ads on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
capi-relay
jean82290/capi-relayMETA_PIXEL_ID
Dataset (Pixel) ID. Meta Events Manager > your dataset > Settings.
ALLOWED_ORIGINS
Your website address(es), comma-separated, e.g. https://myshop.com, https://www.myshop.com
META_ACCESS_TOKEN
Conversions API token. Events Manager > dataset > Settings > Conversions API > Generate access token.

