3. Create a segment

Sync the result of a SQL or visual query to one or more destinations on a fixed interval

Query with SQL

Navigate to the Segments page on the sidebar and start by creating a new segment.

To get started quickly, we'll start by simply using SQL to create your first segment. Hit "New SQL Query" on the top left, and use a simple query like:


This will depend on the schema of your database or data warehouse, but this query will return us a list of all our users.

Caveat: For now, every query being synced to destinations must return a unique id column. If you do not have an id column, you can alias a column to id in your SQL query (e.g. select user_id as id, first_name, last_name).

The id column is used by Hightouch to differentiate between new rows and changed rows when diffing results between consecutive runs before sending changes to downstream destinations like HubSpot.

If you want to learn more about exploring your data warehouse with SQL and with our visual query builder, check out the Exploring your data section of our docs.

Adding destinations

In the next step, we can select which destinations we want to send the query results to.

We can always add multiple destinations, but let's take Hubspot as an example. To set up the connection, we have to map the fields in the query results (from the database / data warehouse) to the fields in Hubspot.

Not all fields have to be mapped! If you leave certain mappings empty, the fields simply wont be synced to the object created in Hubspot.

This configuration is specific to each destination that the query results are being sent to. This particular configuration will insert the Hubspot object contacts for each row in the query of users, and map first_name, last_name, email, and location to firstname, lastname, email, and city respectively.

For more information on the configuration of each destination, check out the Destinations section of the documentation.

Schedule your syncs

Lastly, we have to schedule how often the query is run and subsequently synced to your destinations.

Your segment can be synced at per minute, hourly, daily, and weekly intervals.