Segment
Read time: 3 minutes
Last edited: Oct 16, 2024
Overview
This topic explains how to create and test a Segment destination for Data Export.
Prerequisites
There are two prerequisites to configure the Segment integration:
- You must add the LaunchDarkly Source in Segment
- You must find the Write Key for your Segment account
First, add the LaunchDarkly Source in Segment. To add the source, read Segment's documentation.
Next, configure the Segment integration in LaunchDarkly. To do this, you need the Write Key from your Segment account.
To find the write key:
- Log into Segment and navigate to your project.
- Navigate to Sources and select your LaunchDarkly source.
- Select API Keys on the Source integration's menu bar.
- Copy the Write Key as shown in the text box:
Create a Segment destination in LaunchDarkly
To create the Segment destination:
- Navigate to the Integrations page and find "Segment."
- Click Add integration. The "Create a destination" panel appears.
- (Optional) Give your integration a human-readable Name.
- Choose an Environment for this integration to apply to.
- Enter the Segment Write key.
- Click Save destination. The new integration appears in the list of integrations.
Test a Segment destination
After you save the destination, send a test event to confirm that the destination is configured properly.
To send a test event:
- Navigate to the Integrations page and find "Segment."
- Click into the "Segment" section to display a list of destinations.
- Click the pencil icon next to the destination you want to test. The "Edit destination" panel appears.
- In the "Send a test event" section, click Send event.
- Verify the event appears in the Segment Debugger.
Example events
These example events display the structure of the events LaunchDarkly sends to Segment.
LaunchDarkly sends events in the following formats:
{"event": "feature","integrations": {},"messageId": "c2f7a2d1-0a1b-456f-8e9a-16756e7a6db5","originalTimestamp": "2019-09-13T21:20:18.114Z","properties": {"project": "5744c12345c9900708000001","environment": "5d4b12345d2a2806bd2cc6eb","eventId": "5d7c12345a51a0006e16ae5","default": "true","flagVersion": 42,"key": "EXAMPLE-FLAG-KEY","prereqOf": "EXAMPLE-PARENT-FLAG","reasonKind": "FALLTHROUGH","value": "EXAMPLE-FLAG-VALUE","variation": 1,"version": 1},"receivedAt": "2019-09-13T21:20:19.406Z","sentAt": "2019-09-13T21:20:19.366Z","timestamp": "2019-09-13T21:20:18.153Z","type": "track","userId": "EXAMPLE-USER-ID"}
{"event": "click","integrations": {},"messageId": "18925338-0a1b-4521-a36a-c8e9839e4593","originalTimestamp": "2019-09-13T21:21:43.114Z","properties": {"project": "5744c98765c9900708000001","environment": "5d4b12345d2a2806bd2cc6eb","eventId": "5d7c123a86f26000065862da","key": "EXAMPLE-FLAG-KEY","selector": "btn","url": "http://example.com","version": 1},"receivedAt": "2019-09-13T21:21:46.415Z","sentAt": "2019-09-13T21:21:46.375Z","timestamp": "2019-09-13T21:21:43.154Z","type": "track","userId": "EXAMPLE-USER-ID"}
{"event": "custom","integrations": {},"messageId": "d747a382-0a1b-41d5-b9a6-7ae9b93925bc","originalTimestamp": "2019-09-13T21:21:58.114Z","properties": {"project": "5744c12345c9900708000001","environment": "5d4b12345d2a2806bd2cc6eb","eventId": "5d7c123452db400061b14dd","key": "EXAMPLE-EVENT-KEY","version": 1},"receivedAt": "2019-09-13T21:22:00.673Z","sentAt": "2019-09-13T21:22:00.393Z","timestamp": "2019-09-13T21:21:58.393Z","type": "track","userId": "EXAMPLE-USER-ID"}
{"integrations": {},"messageId": "8c235148-0a1b-4428-a4de-00b90adf2833","originalTimestamp": "2019-09-13T21:19:43.114Z","properties": {"project": "5744c123459900708000001","environment": "5d123454d2a2806bd2cc6eb","eventId": "5d7c12345db400061b14c1","key": "EXAMPLE-FLAG-KEY","url": "http://example.com","version": 1},"receivedAt": "2019-09-13T21:19:45.371Z","sentAt": "2019-09-13T21:19:45.331Z","timestamp": "2019-09-13T21:19:43.154Z","type": "page","userId": "EXAMPLE-USER-ID"}
Enable Data Export for flags and environments
After you create a Data Export destination, you must start sending flag or environment event data to it. You can enable Data Export for individual flags, or for all the flags in an environment.
To learn more, read Export event data for flags and environments.
Delete a Segment destination
You can delete a Data Export destination from the Integrations screen.
To delete a destination:
- Navigate to the Integrations page and find "Segment."
- Click into the "Segment" section to display a list of destinations.
- Click the pencil icon next to the destination you wish to delete. The "Edit destination" panel appears.
- Click Delete destination.