With Amplitude’s LaunchDarkly integration, you can export your Amplitude cohorts and use them as segmentation and targeting criteria in LaunchDarkly. From there, you can create feature flags for specific segments of users defined by your Amplitude data.
This article will explain how to set up and use the integration.
To set up the integration, follow these steps:
- Navigate to Sources & Destinations --> Destinations and click the LaunchDarkly destination.
- From inside your LaunchDarkly console, navigate to Account Settings → Authorization. Click + Token. In the panel that appears:
- Name the token;
- Select Writer from the Role dropdown list; and
- Select the appropriate API version from the API version drop-down list.
- Click Save Token.
Once the token is created, you’ll find it listed in the Authorization tab.
- Next, return to the Projects tab and copy the client side ID from the project you want to export Amplitude cohorts to.
- Returning to Amplitude, enter the client side ID and app token into the Amplitude Destination setup. Be sure to specify the user identifier Amplitude will use to sync with LaunchDarkly.
NOTE: You must make sure to choose a matching user identifier in Amplitude and LaunchDarkly. This is often userID, but could also be a device ID. If they don't match, it won’t work.
Export cohorts to LaunchDarkly
Once LaunchDarkly is connected to Amplitude, you can sync any Amplitude cohort to it. To do so, follow these steps:
- Open the cohort you want to export. Click Sync To, and choose LaunchDarkly from the drop-down list.
- In the modal that appears, choose the LaunchDarkly app you configured.
- Select the sync frequency you need: one-time, hourly, or daily.
- Click Save Sync to complete the process.
After the cohort is synced with LaunchDarkly, Amplitude will create a LaunchDarkly “segment.” You’ll see it in the Segments section in LaunchDarkly (there’ll be an Amplitude logo next to it). You can then use this segment for targeting rules in feature flags you set up in LaunchDarkly.