Skip to content

External segments

External segments let you target users 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.

For a database, 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. You can also use a Google Analytics 4 audience, which needs no query. 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 with its menu item, 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
    • Microsoft SQL Server / Fabric
    • Google Analytics 4 audience
Create external segment form with the Name filled in and Database type set to Microsoft SQL Server / Fabric

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, because MySQL connections don’t use TLS): whether and how the connection to your database is encrypted with SSL/TLS. 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, you can add certificates under Certificate source: upload files or paste them in PEM format. All certificate fields are optional:
    • CA certificate: add it for the Verify CA or Verify full mode if your server’s certificate is self-signed or issued by a private CA. Without it, Pushwoosh checks the server against publicly trusted CAs. The Require mode ignores this field.
    • Client certificate and Client key: add them if your database requires client certificate authentication.
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

Google Analytics 4 audience

Anchor link to

A Google Analytics 4 audience segment takes its users from an audience you built in Google Analytics, so it has no query. Fill in:

  • GA4 property ID: the ID of the Google Analytics property, shown in Google Analytics under Admin → Property details.
  • Service account JSON: the key for a service account with the Viewer role on that property. Grant the role in Google Analytics under Admin → Property access management, and enable the Google Analytics Data API and Admin API in the service account’s Google Cloud project.
  • Audience: click Load audiences, then choose the audience. If the list is empty, create an audience in Google Analytics first.
Google Analytics 4 audience form with GA4 property ID, Service account JSON, the Purchasers audience, and Check connection

For the setup on the Google Analytics side, see Google Analytics integration. Then click Check connection. When the check succeeds, click Create.

Enter the query

Anchor link to

For every database type except Google Analytics 4 audience:

  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, each time the segment is used, Pushwoosh checks how long ago it was last refreshed successfully:

  • 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, or the segment has never been refreshed successfully, Pushwoosh waits for a fresh refresh before it uses the segment.

A Google Analytics 4 audience segment follows the same rules, with 24 hours and 72 hours instead of one hour and three hours. Google Analytics updates audience membership about once a day.

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 users are in the segment

Anchor link to

To see how many users are in the segment, read the Users column on the External segments list. It holds the last successful count, which Pushwoosh updates after each refresh (see How the segment stays up to date):

  • M of N: the query returned N IDs, and M of them are User IDs your app sets in Pushwoosh. Only these M users are in the segment.
  • Not found: K means that K IDs from the query don’t match any User ID of your app. Pushwoosh skips these IDs.
  • A dash: Pushwoosh has no count yet, or the last refresh returned no IDs. A refresh starts only when the segment is used, for example by a campaign or journey. If the dash stays after that, run the query in your database to confirm it returns rows. If it does, contact Pushwoosh support.

When any segment on the list has Not found IDs, a warning banner appears above the list. This isn’t an error. The segment stays valid and reaches the M users it matched.

To fix Not found IDs, change the query to return the User ID your app sets in Pushwoosh. If the skipped IDs belong to users of your app, the query likely returns a different identifier, such as a CRM key or an email address. To see which User ID a user has, look them up in User Explorer.

In this list, one segment has Not found IDs and one has no count yet:

External segments list with four segments showing name, code, database type, host, Users counts, and status, and the warning banner about IDs that are not Pushwoosh users

To see how many devices the segment reaches, open the segment of the same name 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.
  • The database type.
  • The host, the project ID for BigQuery, or the property for a Google Analytics 4 audience, as properties/<ID>.
  • Users: how many of the IDs your query returned are User IDs of your app, as “M of N”, and how many were not found (see Check how many users are in the segment).
  • The status, valid or invalid.

Each row also has two buttons:

  • 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 an in-app message, an RSS feed, a news feed campaign, a preset, a running or paused journey, another filter, a feature flag, or a popup form. Remove those references first, then delete the segment. This cannot be undone.