Skip to main content
All Collections3rd-party integrationsCDPs
How to connect Batch to Segment?
How to connect Batch to Segment?

Send attributes, events, custom audiences and more from Segment to Batch.

Laurent Canestrier avatar
Written by Laurent Canestrier
Updated over 6 months ago

Segment.com is a customer data platform that simplifies the data collection process by providing a central point for storing and transferring data. We give an example of an integration with Segment so that you can send your data directly from Segment to Batch.

This integration uses a Segment feature called Destination Function.

If you are interested in this example of integration, please contact us at: partners@batch.com

How can I use my Segment data on Batch? 

Here is how you can create a custom Destination Function to send attributes and events to Batch.

Note: If you are an omnichannel or email client, the sample code will allow you to set up flows to send project-level data using the Profile API.

Create a Destination Function

Destination functions allow you to handle your Segment events and send them to any external tool or API, through JavaScript functions, without having to set up an infrastructure.

To create a Destination Function in Segment, you can navigate through Connections > Catalog > Functions > Destination Functions.

Then, we suggest you use our pre-built script to create your function and adapt it to your use cases.

Segment has a built-in testing module that will help you understand if your Function calls Batch APIs as wanted. Try it using your events payloads.

Segment’s testing module

Deploy as a Destination

Once your script is ready, you can Save & Deploy your function into a destination.

  • Pick one source. It could be any of your sources: iOS, Android, Web, or other.

  • Declare settings. They are a good option to store your API Keys. To ensure that the script recognizes the API keys, please name them as follows: batchRestApiKey, batchLiveApiKey or batchProjectApiKey. The REST API Key is sensitive, you must declare it as such.

N.B.: The Project API Key is optional. It is only necessary if you need to call project-level APIs (e.g. the Profile API).

Settings tab in Segment Functions interface

  • Activate the Destination so that data starts flowing between Segment and Batch.

You should note that a Destination is an instance of a Destination Function.

If you have several sources plugged into Segment, you must create one Destination per source. However, you can use the same Function for all Destinations, as long as your events are handled correctly within the Function.

Batch is now registered as a Destination.

How to send audiences from Segment to Batch?

Here is how you can create a custom Destination Function to send custom audiences to Batch.

You must follow the following steps in that order :

  1. Create your Destination Function

  2. Create your Destination

  3. Create a filter in your Destination. Filter out all events that are not of event type “Track”. You can use “Only Send Event” > “Event Type is track”

  4. Create your Segment Audience and send its events to the Batch Destination

Note: Steps 1, 2 & 3 must be done only once for the technical setup. Then, your marketing teams only need to follow step 4 to create new audiences.

1. Create a Destination Function

Destination functions allow you to handle your Segment events and send them to any external tool or API, through JavaScript functions and without having to set up an infrastructure.

To create a Destination Function in Segment, you can navigate through Connections > Catalog > Functions > Destination Functions.

Then we suggest you use our pre-built script to create your function and adapt it to your own use cases.

Segment has a built-in testing module that will help you understand if your Function calls Batch APIs as wanted. Try it using your audience events payloads (Track and Identify).

Segment’s testing module

2. Deploy as a Destination

Once your script is ready, you can Save & Deploy your function to a destination.

  • Pick one source. You need to use your Unify Personas Space because that's where your audience-related events will flow.

  • Declare settings. They are a good option to store your API Keys. To ensure that the script recognizes the API keys, please name them as follows: batchRestApiKey and batchLiveApiKey The REST API Key is sensitive, you must declare it as such.

Settings tab in Segment Function interface.

  • Activate the Destination so that data starts flowing between Segment and Batch.

You need to deploy one destination for each Batch app (e.g. one destination for the iOS app and one destination for the Android app).

3. Create your Segment Audience

Pre-requisite: To create Audiences, you will need to have created a Unify / Personas space and declared data sources.

  • In Engage > Audiences, create an audience with the audience builder.
    You can target events from your data sources and create your audiences accordingly. There are several computing methods available. Please refer to Segment’s Audience Documentation to understand it better.

  • Once your audience is designed, choose to send events to one or multiple Batch Destinations created beforehand.

  • In the menu that opens, select "Send Track".
    Note: The values of the "Enter Event" and "Exit Event" fields don't matter.

Give your audience a name and the audience creation will be complete:

Batch is a Destination of the Audience.

🎉 Your audience will be initialized in Segment and created in Batch immediately. The audience will be updated in Batch each time a user enters or leaves it.


👉 Any more questions?

Don't hesitate to ping us on the live chat at the bottom right of your screen 😉


This article belongs to Batch's FAQ. Need more help? Find insightful articles, documentation, case & market studies, guides, and even more in our website's Resources section on batch.com and our blog.

Did this answer your question?