Fetch Segment Profile Data in Pendula

Josh Stylianou
Josh Stylianou
  • Updated

A GET request to Segment can be used at any point in a flow to utilise additional information about a profile. This can take the form of:

  • Profile Traits
  • Profile Events
  • Profile External IDs
  • Profile Metadata
  • Profile Links

An example of when to fetch data would be to get a customer's name and phone, when the initial triggering event only contains a UserID. 

 

Segment Flow example

Pre-requisites

To fetch Segment Profile Data within a Pendula flow, you'll need:

  • A Segment Business plan, with Unify
  • A set of Segment web request credentials - see Segment Documentation for details.
  • Request Headers setup within Pendula, with the Segment generated web request credentials.
    • Header - Authorization
    • Value - Base64 encoded access token:
      • The colon is necessary - Segment requires a blank password after the base64 encoded access token.

Creating a Pendula Web Request to Segment

  1. Drag the Web Request node into your flow at the point where you want to fetch Segment profile data.
  2. Set the Request type to GET.
  3. Select Headers from the Authentication drop down.
  4. Select the credential you have configured for Segment.
  5. Copy and paste the following into the API endpoint URL field:
    https://profiles.segment.com/v1/spaces/SpaceID/collections/users/profiles/User_id:UserID/Route
      • SpaceID is supplied based upon Segment Space ID (in Unify Settings → API Access)
      • User_id is an external ID that is tracked within Segment profiles as an Identifier.
      • UserID should be a merge field that identifies the specific profile.
      • Route depends on what should be returned by the request. e.g. traits
      • By default, the response includes 20 records. You can return up to 200 records by appending ?limit=200
      • See Segment Profile Documentation for further information around Profile API. 
  6. Paste a payload sample of traits into the node for reference within the flow. It should look similar to below:
    • {
      "traits": {
      "email": "example@gmail.com",
      "logins": 5,
      "name": "Example",
      "phone":"6140000000",
      "plan": "premium"
      }
      }