---
title: "Deploy CAPI Relay | Server-Side Tracking for Facebook & Instagram Ads"
description: "Consent-first server-side Conversions API for your Pixel, GDPR-ready"
category: "Analytics"
url: https://railway.com/deploy/capi-relay-or-server-side-tracking-for-f
---

# Deploy CAPI Relay | Server-Side Tracking for Facebook & Instagram Ads

Consent-first server-side Conversions API for your Pixel, GDPR-ready

**[Deploy CAPI Relay | Server-Side Tracking for Facebook & Instagram Ads on Railway](https://railway.com/template/capi-relay-or-server-side-tracking-for-f)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/capi-relay-or-server-side-tracking-for-f/manifest.json

- **Creator:** jean82290's Projects
- **Category:** Analytics
- **Total deploys:** 1

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### capi-relay https://raw.githubusercontent.com/jean82290/capi-relay/main/assets/icon.svg

- **Source:** jean82290/capi-relay
- **Health check:** /healthz
- **Public domain:** Yes

## Documentation

# Deploy and Host CAPI Relay | Server-Side Tracking for Facebook &amp; 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 &amp; 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 &amp; 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

```html



```

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 &amp; 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 &amp; 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.



## Similar templates

- [Plausible WordPress](https://railway.com/deploy/deploy-plausible-for-wordpress-sites) — Cookie-free WordPress stats from your own Plausible
- [Typesense Multilingual](https://railway.com/deploy/deploy-typesense-multilingual-search) — Locale-aware multilingual search with Typesense
- [Formbricks](https://railway.com/deploy/formbricks-surveys) — Surveys, NPS and in-app feedback on your own Postgres, Hub and Cube

Open this page in a browser: https://railway.com/deploy/capi-relay-or-server-side-tracking-for-f
