Connectors / Service / Segment

Analytics (updated: 1534759386059)


Segment is an analytics API and customer data platform that allows you to easily move data between different sources and destinations.


API INFO: The Base URL used for the Segment connector is More information can be found on their main API documentation (v1.0) site. This is where users will also be able to find the API Limitations page.

Below is an example of a way in which you could potentially use the Segment trigger to track any actions on your Source website and fire the trigger when a specified action is performed. The JSON data then received through the trigger is managed through different branches based on the event.

The Source considered in this example is a Training website that sells various training courses. We create individual branches based on the events that occur on the Training website's sales page.

Below is some sample data that comes via the source website:

"_metadata": {
"bundled": [
"Visual Tagger"
"bundled_ids": [
"unbundled": [
"anonymous_id": "kwednxxx-xxx-xx-xxx-xx497nfbhd",
"channel": "client",
"context": {
"campaign": {
"content": "john-live",
"medium": "yt-description",
"name": "yesterday-live",
"source": "youtube"
"ip": "",
"library": {
"name": "analytics.js",
"version": "4.1.8"
"locale": "en-gb",
"page": {
"path": "/pwj",
"referrer": ""
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15"
"event": "Sales Page Visited",
"integrations": {},
"message_id": "ajs-78456xxxxxxxxxxxu934422",
"original_timestamp": "2021-05-25T08:44:37.279Z",
"project_id": "q2dfhexxxxxxxkdspofk",
"properties": {
"course_name": "JS",
"currency": "USD",
"utm_campaign": "yesterday-live",
"utm_source": "youtube",
"value": 420
"received_at": "2021-05-25T08:44:38.777Z",
"sent_at": "2021-05-25T08:44:37.280Z",
"timestamp": "2021-05-25T08:44:38.776Z",
"type": "track",
"user_id": null,
"version": 2

The following workflow gives an example of how you can achieve this:


EXTRA AUTHS: In order to complete this workflow, you will also need to be authenticated with the Google Sheets connector.

1 - Setup Segment Trigger & the branches

Select the Segment trigger from the trigger options available and set the operation to 'On page track'.

There are various operations that the Segment trigger facilitates, and you can choose any based on your needs. To know more about the Segment Trigger, you can refer to the Trigger Setup section above

Add a Branch connector to your workflow. Then, using the connector-snake, find the jsonpath for the 'Value To Test' field from the trigger. It should appear similar to this: $.steps.trigger.event.

JSONPATHS: For more information on what jsonpaths are and how to use jsonpaths with, please see our Intro page and Data Guide for more details.

CONNECTOR-SNAKE: The simplest and easiest way to generate your jsonpaths is to use our feature called the Connector-snake. Please see the main page for more details.

The next step is to name the branches. These names depend entirely on the events that you wish to track and take necessary actions accordingly.

In this example, the considered events are Sales Page Visited, Checkout Started, and Order Completed. Thus the three branches. The last branch is a Default branch, which is auto-created and manages all the other events except the ones specified above.


Feel free to re-name your steps as you go along to make things clearer for yourself and other users. However, the operation names themselves often suffice.

Once we have set up the trigger and the Branch connector, the workflow will listen to any page view events on our source website, and then based on the current event type, the respective branches will take specific actions.

2 - Create event-based branches

As the next steps, the workflow will execute based on the events specified in the Branch step:

Branch-1: Sales Page Visited

On the Sales Page Visited event, as a first step the Segment connector is identifying the Sales page visitor.


Based on the output of the initial step, i.e., Successful or Unsuccessful, the Boolean Condition connector is checking if the visitor is known?


If the visitor is known, then no action is needed, and thus the workflow terminates.

If the visitor is unknown, then the Segment connector using the Get Profile Traits (Alpha) operation is identifying the traits of the visitor based on the 'anonymous_id'. Traits are pieces of information you know about a user.


In the end, the newly gathered traits are stored in a third-party service. In this case, we are using google sheets as a generic placeholder for any service or database you may wish to use.

Branch-2: Checkout Started

On the Checkout Started event, as a first step, the Segment connector is identifying the traits of the visitor as we did in the previous step.

As a next step, the Segment connector is identifying the traits of the visitor using an email address.

The second check is precautionary and optional.


As the email address field is not mandatory, there are chances that the value for the email field may not be available. In such a situation, the workflow will prompt an error and stop the further execution as it is its default mechanism.

To handle this situation, we are using the Manual Error handling mechanism. To select Manual Error handling for the Personas Get Traits (email) step in the properties panel, click 'Handle errors' and set the error handling to 'Manual'.


This error handling method gives you two branches:

  • Success: This means the email is available, and the step could return visitor traits using the email address. Then we merge the traits from both the steps, i.e., Personas Get Traits and Personas Get Traits (email) using an Object Helpers, and store this merged info in a Google Sheet.

  • Error: This means the email address is not available, then we are storing the data only from the Personas Get Traits step into the excel sheet.

Branch-3: Order Completed

The Order Completed branch sends a message on the selected Slack channel notifying that a specific order is completed.

This Notification can be further used in various ways based on your requirements.

Again as we did in the previous two branches, as a first step, the Segment connector is identifying the traits of the visitor.

Using this traits information a Slack message would be sent on the selected channel.


BEST PRACTICES: Whenever you do decide to create your own workflow, please make sure you take a look at our managing data best practices guide.

All Operations

Latest version:


Alias identities

The alias method is used to merge two user identities, effectively connecting two sets of user data as one.


Track one or more events to Segment in one batch, to keep API calls efficient.

Get Profile External ID's (Alpha)

Get a single profile’s external ids within a collection using an external_id.

Get Profile Properties (Alpha)

Get a single profile’s properties within a collection using an external id.

Get Profile Events (Alpha)

Get a single profile’s events within a collection using an external ID.

Group user

The group method lets you associate a user with a group, like an account or organization.

Identify user

The identify method is how you tie one of your users and their actions to a recognizable userId and traits.

Track event

The track method is how you record any actions your users perform.

Track page

The page method lets your record whenever a user sees a page of your website.

Get Profile Traits (Alpha)

Get a single profile’s traits within a collection using an external_id.