Introduction

This guide covers implementing Descope's segment connector. Segment is an analytics product that allows you to collect events from web and mobile apps. Descope enables you to capture data from Segment to better understand your customer's needs.

Configure Segment connector

Descope uses your Segment Write Key to programmatically send event updates during your authentication flow. Start by navigating to the Descope Segment connector: Connectors then select Segment

Now, complete the required fields:

  • Connector name: Custom name for your connector. This will come in handy when creating multiple connectors from the same connector template.
  • Write Key: The Segment Write Key generated for the Descope service. Read more on how to find it in Segment's documentation.

You can also configure the optional fields:

  • Connector description: Describe what your connector is used for.
  • Custom base URL: The base URL of the Segment API, when using a custom domain in Segment.
You can test if your connector's configuration is working properly simply by hitting the Test button and viewing the Test Results panel.

Descope example segment connector configuration.

Save your configuration by hitting Create.

Add your Segment connector to a flow

Navigate to: Flows, choose your flow. Then, tap the create button (designated via the + icon), select Connector, and choose the Segment tracking option you'd like.

Click to set down the connector in your flow editor and fill out the fields:

  • User ID: The unique ID of the user
  • Anonymous ID: The ID associated with your user when you don't know who they are
  • Traits: A dictionary of traits you want to record on your user, like email or name.

Start typing in the empty field to view attribute options. For the User ID, you could use the {{user.userId}} field.

Now, link your connector in your authentication flow, making sure it's placed after any required attributes you just chose are defined. Simply by adjusting the attributes and location of the connector, you can track anything from a user sign up/in to the method used for authentication.


Descope example segment connector within flow.

That's it! Whenever a user goes through your authentication flow, the Segment connector will be automatically triggered and the event will appear in your Segment workspace.

Handle errors

The Segment connector allows for custom handling of errors. After adding the connector (track or identify) to a flow, you can scroll down to the 'Error Handling' section. There, you can change the error handling from 'Automatic' to 'Custom', then link to a custom error handling flow.

Descope example segment connector error handling configuration within flow.
Descope example segment connector error handling connection within flow.