Skip to content

External segments

External segments let you target people already stored in your own database, like your CRM or data warehouse, instead of exporting them to a CSV and re-uploading it every time the list changes. You give Pushwoosh a SQL query that returns the right user IDs, and Pushwoosh keeps rerunning that query to keep the segment up to date. Once it’s set up, you can use these users the same way as any other segment.

Setting up a connection touches your production database. Before you start, have your developer or database administrator:

  • Prepare a read-only user (or, for BigQuery, a read-only service account)
  • Confirm the query you plan to use
  • If the database is behind a firewall, ask Pushwoosh support which IP addresses to allow

Create an external segment

Anchor link to

Name the segment and choose the database

Anchor link to
  1. Go to Audience → External Segments.
  2. Click Create external segment.
External Segments page in the Control Panel showing the empty list and the Create external segment button
  1. Enter a Name for the segment (up to 100 characters).
  2. Choose the Database type: PostgreSQL, MySQL, Google BigQuery, or Microsoft SQL Server / Fabric.
Create external segment form showing Name and Database type with PostgreSQL, MySQL, Google BigQuery, and Microsoft SQL Server / Fabric options

Fill in the connection fields

Anchor link to

PostgreSQL and MySQL

Anchor link to

For PostgreSQL and MySQL, fill in:

  • Host and Port: the address of your database server. Pushwoosh requires a publicly reachable host and rejects private, internal, or loopback addresses when you check the connection or save the segment.
  • Database: the database name.
  • User and Password: credentials for a read-only account.
  • SSL mode (PostgreSQL only, since MySQL connections don’t use TLS) sets how SSL/TLS, the protocol that encrypts the connection, applies to your database connection. Ask your database administrator which mode to use:
    • Disable: no encryption.
    • Require: encrypts the connection, but doesn’t check the database server’s identity.
    • Verify CA: encrypts the connection and checks that the server’s certificate was issued by a trusted certificate authority (CA).
    • Verify full: same as Verify CA, and also checks the certificate matches your database’s hostname. The strongest option.
  • For any mode other than Disable, provide the CA certificate under Certificate source (Upload files or Paste PEM), plus a Client certificate and Client key if your database requires them.
External segment creation form with PostgreSQL connection fields, SSL mode set to Require, and certificate upload fields

For Google BigQuery, fill in:

  • Project ID: the GCP project that holds your dataset.
  • Service account JSON: the key for a service account with BigQuery read access.
  • Location: the dataset’s region (for example, EU, US, or europe-west3). Leave it empty to resolve the location automatically from the dataset.
External segment creation form with BigQuery connection fields: Project ID, Service account JSON, and Location

SQL Server / Fabric

Anchor link to

For Microsoft SQL Server / Fabric, fill in:

  • Host and Port: the address of your database server, or your Fabric SQL analytics endpoint. Pushwoosh requires a publicly reachable host and rejects private, internal, or loopback addresses when you check the connection or save the segment.
  • Database: the database name.
  • User and Password: credentials for a read-only account.
  • Microsoft Entra tenant ID: optional. Leave it empty for a SQL Server login. For Microsoft Fabric, whose SQL analytics endpoint has no SQL logins, set it to sign in as a service principal instead. Enter its application (client) ID as User and its client secret as Password.
External segment creation form with Microsoft SQL Server / Fabric connection fields: Host, Port, Database, User, Password, and Microsoft Entra tenant ID

Enter the query

Anchor link to
  1. Enter the Query. It must return a single column named user_id, with one row per user you want in the segment. For example:
SELECT user_id FROM loyalty_members WHERE tier = 'gold'
  1. Click Check connection to confirm Pushwoosh can reach the database (times out after 30 seconds).
  2. Click Check query to confirm the query runs and returns the right column (also times out after 30 seconds).
Query field with an example SQL query, the user_id column requirement, and the Check connection and Check query buttons

Verify and create

Anchor link to

When both checks succeed, click Create. Pushwoosh saves the segment and adds it to the External Segments list right away.

How the segment stays up to date

Anchor link to

Pushwoosh doesn’t run your query on a fixed schedule. Instead, it refreshes the segment based on how recently it was last used:

  • If the segment’s data is less than an hour old, Pushwoosh uses the current data as-is.
  • If it’s older than an hour, Pushwoosh keeps using the current data while it refreshes in the background.
  • If it’s older than three hours, Pushwoosh waits for a fresh refresh before it uses the segment.

In practice, this means a segment you use regularly (for example, in a recurring journey) stays current, while a segment you rarely touch may take a moment to refresh the first time you use it again.

If a refresh fails (for example, the database becomes unreachable or the query starts erroring), Pushwoosh records the error, but the segment’s status on the External Segments list doesn’t change on its own. After you’ve fixed the issue on your end, open the segment and click Check connection to confirm the fix. The error clears automatically the next time the segment’s data refreshes successfully.

Use an external segment

Anchor link to

Once you’ve created it, the external segment automatically appears on Audience → Segments under the same name, ready to use like any other segment, for example as a campaign or journey audience.

To combine it with other conditions, add it as a filter:

  1. Go to Audience → Segments → Create Segment.
  2. Click Add filter by → Segment.
  3. Select your external segment by name.

The same Segment filter is available in compound filters and when you choose the audience in Audience-based entry. For more on combining segments, see Build segments by existing segments.

Check how many people are in the segment

Anchor link to

The External Segments list doesn’t show a member count. Open the segment’s wrapper on Audience → Segments (see Use an external segment) and calculate its size there.

Manage external segments

Anchor link to

On the External Segments list, each row shows the segment’s name, Code (the identifier used to reference the segment in API calls), database type, host, and status (valid or invalid).

External Segments list with a PostgreSQL segment showing name, code, database type, host, and valid status
  • Click Edit to change the connection or query. The database type can’t be changed after creation. Create a new segment instead.
  • Click Delete to remove a segment. Pushwoosh blocks the deletion while the segment is used by a campaign, journey, filter, or popup form. Remove those references first, then delete the segment. This cannot be undone.