PostgreSQL
Datafly Signal writes first-party events into a PostgreSQL table for reliable relational storage with advanced JSONB querying and the full Postgres extension ecosystem.
Why route PostgreSQL through Datafly Signal
- The data lands in infrastructure you own. Signal writes to your PostgreSQL directly from your own deployment. Datafly operates no intermediary and never holds a copy of your event data.
- Personal data is hashed on the way in. Email, phone (shaped to E.164 first), first, last and full name and postcode are normalised (trimmed and lower-cased) and hashed with SHA-256 inside your own deployment, so the table holds
email_sha256,phone_sha256and the other digests rather than the raw values. Storing a raw value is a deliberate edit to the installed blueprint. - Only what the blueprint maps is stored. The properties Signal writes are exactly the fields the blueprint maps. Identify traits and client properties the blueprint does not map are never written, so a stray email in an event property cannot land in PostgreSQL in plain text.
- Presets for Retail, Insurance, Travel, Media & Streaming, B2B / SaaS, Automotive and General. Each vertical preset names one field per property in the matching event spec, with canonical names (
transaction_id,value,items), legacy aliases (order_id,revenue,products) read automatically, numbers typed as numbers and currency codes upper-cased. - Client IP and user agent are recorded as event context. Both come from the original visitor request rather than from your server, so geography and device analysis done in the warehouse reflects the actual visitor.
- One consent decision governs every destination. PostgreSQL is gated by the same consent state as the rest of your stack, so a withdrawal applies everywhere at once.
Prerequisites
Before configuring PostgreSQL in Signal, you need a PostgreSQL server (self-hosted or managed), a database with a schema and table, and a user with INSERT privileges.
Set Up a PostgreSQL Server
You have several options:
Option A: Managed PostgreSQL
- Amazon RDS for PostgreSQL — Create an RDS instance
- Azure Database for PostgreSQL — Create an Azure PostgreSQL server
- Google Cloud SQL for PostgreSQL — Create a Cloud SQL instance
- Supabase, Neon, Aiven, or other managed providers
Option B: Self-Hosted PostgreSQL
- Install PostgreSQL using the official guide.
- Start the PostgreSQL server.
- Ensure it is accessible from your Signal infrastructure on port
5432.
Configure Network Access
Ensure your PostgreSQL server accepts connections from Signal’s IP addresses:
- RDS: Configure the security group inbound rules on port
5432. - Azure: Add firewall rules in the Networking tab.
- Cloud SQL: Add authorised networks.
- Self-hosted: Configure
pg_hba.confand firewall rules.
Create a Database, Schema, and Table
Connect to the PostgreSQL server and create the target resources:
CREATE DATABASE datafly_events;
\c datafly_events
CREATE SCHEMA IF NOT EXISTS datafly;
CREATE TABLE datafly.events (
message_id TEXT PRIMARY KEY,
event_type TEXT NOT NULL,
event_name TEXT,
anonymous_id TEXT,
user_id TEXT,
ip_address TEXT,
user_agent TEXT,
page_url TEXT,
page_path TEXT,
page_referrer TEXT,
org_id TEXT,
pipeline_id TEXT,
event_timestamp TIMESTAMPTZ,
received_at TIMESTAMPTZ,
properties_json JSONB,
context_json JSONB
);
CREATE INDEX idx_events_ts ON datafly.events (event_timestamp DESC);
CREATE INDEX idx_events_name ON datafly.events (event_name, event_timestamp DESC);Signal inserts exactly these column names. message_id must be the primary key (or have a unique index): Signal inserts with ON CONFLICT (message_id) DO NOTHING so a redelivered event is not stored twice. JSONB enables indexing and the ->, ->> and @> operators.
Create a User for Signal
CREATE USER datafly_signal WITH PASSWORD 'your_secure_password';
GRANT USAGE ON SCHEMA datafly TO datafly_signal;
GRANT INSERT ON TABLE datafly.events TO datafly_signal;
GRANT SELECT (message_id) ON TABLE datafly.events TO datafly_signal;The SELECT on message_id alone is required: PostgreSQL checks the conflict target of INSERT ... ON CONFLICT (message_id) DO NOTHING with the inserting user’s privileges, so a user with INSERT only fails every insert with permission denied for table events.
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
host | string | Yes | The PostgreSQL server hostname. |
port | string | Yes | The PostgreSQL server port. Defaults to 5432. |
database | string | Yes | The target database name. |
schema_name | string | Yes | The schema to write to. Defaults to public. |
table_name | string | Yes | The target table name to insert rows into. |
username | string | Yes | The database username for authentication. |
password | secret | Yes | The database password for authentication. |
ssl_mode | select | No | The SSL mode for the connection: disable, require, verify-ca, verify-full. Defaults to require. |
Signal Setup
Quick Setup
- Navigate to Integrations in the sidebar.
- Open the Integration Library tab.
- Find PostgreSQL or filter by Database.
- Click Install, select a variant if available, and fill in the required fields.
- Click Install Integration to create the integration with a ready-to-use default blueprint.
API Setup
curl -X POST http://localhost:8084/v1/admin/integration-catalog/postgresql/install \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "PostgreSQL",
"variant": "default",
"config": {
"host": "db.example.com",
"port": "5432",
"database": "datafly_events",
"schema_name": "datafly",
"table_name": "events",
"username": "datafly_signal",
"password": "your_secure_password",
"ssl_mode": "require"
},
"delivery_mode": "server_side"
}'Schema
Signal inserts one row per event into exactly these sixteen columns, so the table must have them all (extra columns of your own are fine if they are nullable or have defaults):
| Column | Contents |
|---|---|
message_id | Unique per delivered event; the idempotency key (a redelivery is not inserted twice). |
event_type | track, page, identify, and so on. |
event_name | Signal event name (snake_case), for example purchase. |
anonymous_id | First-party visitor identifier. |
user_id | Logged-in user identifier; NULL when absent. |
ip_address, user_agent | Client IP and user agent from the visitor’s request. |
page_url, page_path, page_referrer | Page context. |
org_id, pipeline_id | Signal identifiers. |
event_timestamp | Client event time (UTC). |
received_at | Time Signal received the event (UTC). |
properties_json | The fields the blueprint mapped, as JSON (below). |
context_json | The event context as JSON: page, device, campaign, consent, IP and user agent. |
Signal inserts with ON CONFLICT (message_id) DO NOTHING, so message_id must be the primary key or carry a unique index; without one every insert fails. Use JSONB for the two JSON columns (a TEXT column also works). Column types are yours to choose as long as the values fit: a value too long for a VARCHAR(n) fails the insert.
What the properties hold
The blueprint decides what properties_json contains, and only mapped fields are written (identify traits and unmapped client properties never are):
- The event’s own fields from the preset sit at the top level, for example
transaction_id,value,currency,items,insurance_typeorpolicy_term_months. - The preset’s global block sits under
@root: copies of the envelope (event_name,event_type,user_id,anonymous_id,event_id,message_id,event_timestamp,page_url,page_referrer,ip_address,user_agent,locale,timezone,source_id),utm_source,utm_medium,utm_campaign, the consent flagsconsent_analyticsandconsent_marketing, and the hashed identityemail_sha256,phone_sha256,first_name_sha256,last_name_sha256,name_sha256. identifyaddsname_sha256andpostal_code_sha256at the top level.- An event the preset does not list stores its envelope and the
@rootblock only.
For example, the purchases with their order ID, value and hashed email:
SELECT event_timestamp,
properties_json->>'transaction_id' AS transaction_id,
(properties_json->>'value')::numeric AS value,
properties_json->>'currency' AS currency,
properties_json->'@root'->>'email_sha256' AS email_sha256
FROM datafly.events
WHERE event_name = 'purchase'
ORDER BY event_timestamp DESC
LIMIT 10;Signal does not write mapped fields to their own columns; create views over properties_json for the fields you query often. What else a row carries outside the blueprint (the whole event context) is under review in #1414.
Stored event context
Alongside the fields your blueprint maps (where email, phone, names and address are stored as normalised SHA-256 by default), each row carries the event’s collected context exactly as Signal received it. The blueprint does not filter or hash the context: this is deliberate (decision 2026-09-23), so the context is complete for attribution, fraud and debugging queries, and it is listed here so you can decide what to keep.
| Stored | What it contains |
|---|---|
| Visitor request | IP address, user agent, Accept-Language, locale and timezone |
| Page | URL including its query string, path, title and referrer |
| Campaign | UTM source, medium, campaign, term and content |
| Consent | The visitor’s consent state |
| Location | GeoIP country, region and city, and the network (ASN) |
| Device | Screen size; for app events the OS and version, manufacturer, model, advertising ID and IDFV when the app collected them |
| Vendor IDs | Cookie and click identifiers in vendor_ids (for example the _fbp browser ID, gclid, ttclid, the GA client ID) |
| Session and library | Session ID, number and engagement time; the collector’s name and version |
| Partner attributes | Profile attributes from partner enrichment (partner_attrs) |
They are written to the ip_address, user_agent, page_url, page_path and page_referrer columns and, in full, to the context_json column, beside anonymous_id and user_id. Click and collected IDs outside the context are stored only where the blueprint maps them.
The IP address, device and advertising IDs, and cookie and click identifiers are personal data under UK and EU GDPR. To keep any of them out of storage, strip, mask or hash the field for every integration with the organisation data layer, apply URL redaction to page URLs, or remove it in the installed blueprint; and set the storage’s retention to match your privacy notice. See Personal data by integration.
Consent
PostgreSQL is a first-party destination under your control, gated by the same consent state as every other destination. Each stored event also records the visitor’s consent at collection time: the preset writes consent_analytics and consent_marketing under @root in the properties (properties_json), and the full consent object is in the context. Use them in views or queries if your governance needs a per-row consent filter.
Testing
- Enable the integration in Signal and trigger a test event on your website.
- Connect to the PostgreSQL server and query the target table:
SELECT message_id, event_type, event_name, event_timestamp
FROM datafly.events
ORDER BY event_timestamp DESC
LIMIT 10;- Verify that event rows are appearing with correct data.
- Test JSONB querying:
SELECT event_timestamp,
properties_json->>'transaction_id' AS transaction_id,
(properties_json->>'value')::numeric AS value,
properties_json->>'currency' AS currency,
properties_json->'@root'->>'email_sha256' AS email_sha256
FROM datafly.events
WHERE event_name = 'purchase'
ORDER BY event_timestamp DESC
LIMIT 10;- In Signal, check the Live Events view to confirm delivery status shows as successful.
Troubleshooting
| Problem | Solution |
|---|---|
| Events not appearing in the table | Verify the host, port, database, schema, and table name are correct. |
| Connection refused / timeout | Check that the PostgreSQL server accepts connections from Signal’s IP. Verify firewall rules, security groups, or pg_hba.conf. |
FATAL: password authentication failed | The username or password is incorrect. Verify the credentials. |
permission denied for schema | The user lacks USAGE on the schema. Run GRANT USAGE ON SCHEMA datafly TO datafly_signal;. |
permission denied for table | The user lacks INSERT on the table, or SELECT on its message_id column (the ON CONFLICT target). Run GRANT INSERT ON TABLE datafly.events TO datafly_signal; and GRANT SELECT (message_id) ON TABLE datafly.events TO datafly_signal;. |
relation does not exist | The table does not exist or the schema is not in the search path. Use the fully qualified name schema.table. |
| SSL connection errors | Verify the ssl_mode setting. Most managed services require require or verify-full. Self-hosted servers may need SSL certificate configuration. |
value too long for type | An event field exceeds the column’s VARCHAR length. Increase the column size with ALTER TABLE, or use TEXT. |
there is no unique or exclusion constraint matching the ON CONFLICT specification | message_id has no primary key or unique index. Add one: ALTER TABLE datafly.events ADD PRIMARY KEY (message_id);. |
Visit PostgreSQL documentation for full SQL reference, JSONB operators, and performance tuning guides.