Keep your team's feature flags up-to-date with fresh targeting rules and lists of users
To get the most out of tools like LaunchDarkly, you'll need to create user segments so that features can be toggled on for specific customers when the time is right. There are two segmentation methods in LaunchDarkly:
- Targeting individual users for inclusion or exclusion (e.g., enable or disable a feature for user #123)
- Targeting all users who satisfy an attribute-based rule (e.g., enable a feature for all users located in Germany)
Both of these methods are limited by the fact that LaunchDarkly can't read user attributes directly from your data warehouse or production database. Instead, LaunchDarkly relies on developers to send user data via the SDK during feature flag evaluation. This is problematic in many common scenarios. For example, you might want to segment users based on attributes that are simply not possible to compute in real-time (e.g., historical usage metrics that require aggregating across large volumes of data).
LaunchDarkly has a limited view of your customers. Hightouch solves this problem by letting you define your user segments on top of your data warehouse or production database. This ensures that your LaunchDarkly segments will always remain in sync with your entire data stack. Feature flags work best when they share a single source of truth with the rest of your business.
We use LaunchDarkly at Hightouch. We built this destination for ourselves, and we think you'll love it too.
- You can do more complex segmentation by leveraging all the data in your warehouse, including event data and third-party data. Your warehouse is the only place where all of this data coexists.
- You can keep your LaunchDarkly segments in sync with the rest of your business tools. For example, you might want to send an email newsletter to users who've been invited to a beta program. You also might want to sync these attributes to a CRM like Salesforce or HubSpot. Hightouch integrates with 100+ SaaS tools used for email marketing, customer support, sales, and more. Define your audience once and activate your data everywhere.
- You don't have to send any sensitive user data to LaunchDarkly. Hightouch determines which users are part of your segment and only transmits the bare minimum information necessary for targeting (usually just a user ID).
- Segments can be defined using the tools that your teams are most comfortable with. You can filter and transform data from your warehouse using SQL or our visual query builder—whichever you prefer. (You can even create LaunchDarkly segments based on work you've already done in dbt or Looker!)
Hightouch can sync data to a LaunchDarkly segment in three ways:
- Target users for inclusion
- Target users for exclusion
- Target users who match a custom rule
We recommend targeting individual users for inclusion/exclusion if LaunchDarkly's feature flagging only affects your application's frontend experience. However, if you intend on feature flagging backend functionality that applies to entire organizations (instead of specific users), it might be better to use rule-based targeting. This is because certain backend logic often cannot be associated with an individual application "user" in the traditional sense. Chat with us if you're not sure which approach to take!
The most common way of using our LaunchDarkly destination is to sync a model containing a list of user IDs for inclusion or exclusion in a particular segment.
In your sync configuration, simply tell Hightouch which field from your model represents the user identifier known to LaunchDarkly.
Sometimes, you might want to sync different users to inclusion and exclusion lists for the same LaunchDarkly segment. This can be accomplished by configuring two separate syncs in Hightouch.
In your sync configuration, you can tell Hightouch to create a new LaunchDarkly segment for you.
You can optionally assign a custom name to your segment. Use the following LaunchDarkly segment naming guidelines:
- All lowercase
- No spaces. Use hyphens instead.
- Must be unique within your LaunchDarkly instance.
If no name is provided, Hightouch will default to using your model name.
Hightouch can also sync your data into a LaunchDarkly rule clause.
Suppose you have a list of email addresses belonging to your sales prospects. You want to immediately enable a feature as soon as they sign up for a trial account. However, you can't predict their user IDs before they've created their accounts. How would you add them to your LaunchDarkly segment in advance?
This scenario is perfect for rule-based segmentation. Your rule clause might look something like this.
Simply create a model that returns a list of email addresses. Then, in your sync configuration, point Hightouch to the desired rule clause. Your LaunchDarkly segment will automatically mirror your Hightouch model. As new email addresses appear, they will be added to the rule clause. The opposite is also true: as email addresses disappear, they will be removed from the rule clause. Simple, right?
Hightouch cannot create new rules on your behalf, so rule-based targeting requires you to initially create each rule inside of the LaunchDarkly web app.
If you're new to Hightouch, be sure to sign up for a free account. Your first destination is free, and LaunchDarkly is a great way to get started.
Before diving into this tutorial, we also recommend reading this article on our core concepts. It's a quick overview of how Hightouch works.
- Log in to LaunchDarkly
- Visit your Account settings page
- Click on the Authorization tab
- Click on Create token
- Give your token a name and assign it the Writer role
- Click Save token and copy the new token that appears in the Authorization page
We recommend using a service token if your LaunchDarkly account is on the Enterprise plan. To do this, simply select This is a service token while creating the token. If you're not on the Enterprise plan, just be mindful that your API token will get revoked (and your Hightouch syncs will fail) if your personal LaunchDarkly account is deactivated for any reason.
- Log in to Hightouch or create a free Hightouch account
- Click on Destinations in the left sidebar
- Click on Add destination in the top right corner
- Select LaunchDarkly in the destination catalog and click Continue to proceed
- Paste your API token into the API Access Token field and click Continue to proceed
- Give your destination a name and unique slug (e.g., “LaunchDarkly Production” and
- Click Finish to create your LaunchDarkly destination!
Now that we've linked Hightouch to your LaunchDarkly account, it's time to connect to build user segments using the data that resides in your data warehouse.
Hightouch sits on top of your data warehouse and can read from Snowflake, Redshift, BigQuery, Databricks, Postgres, MySQL, and many other data sources. You can even fetch data from Google Sheets and Airtable. Hightouch can help activate your data wherever it resides.
We've written dedicated guides for each supported data source. Take your pick:
- Connect to Airtable
- Connect to Amazon Athena
- Connect to Amazon Redshift
- Connect to Clickhouse
- Connect to Databricks
- Connect to Elasticsearch
- Connect to Firebolt
- Connect to Google BigQuery
- Connect to Google Sheets
- Connect to Looker
- Connect to Metabase
- Connect to MySQL
- Connect to Palantir Foundry
- Connect to PostgreSQL
- Connect to Rockset
- Connect to SFTP
- Connect to Snowflake
- Connect to SQL Server
- Connect to Trino
If you're missing the credentials necessary to connect to your data source, try inviting your teammates to Hightouch. You can have unlimited collaborators in your workspace!
Waiting for credentials to your data warehouse? No problem! You can connect to one of our sample databases to get started right away. For the rest of this tutorial, we'll use our demo Postgres database, which contains a
users table with names, emails, locations, and other user attributes. This sample source is available when you log in for the first time—no setup required.
Next, we'll write a SQL query to define which users should be synced to our LaunchDarkly segment.
In Hightouch, a model represents a query that filters or transforms the records in your data source. Models are used to determine exactly which records to sync between sources and destinations.
When you connect to a data warehouse, your models will probably be written in SQL. You can also import models from tools like dbt and Looker.
In this example, we'll keep it simple. Suppose you want to use LaunchDarkly to enable a feature only for your customers located in the city of Nashville. To accomplish this, you'll want to create a model that looks like this:
SELECT * FROM users WHERE location = 'Nashville';
- Click on Models in the left sidebar
- Click on Add model in the top right corner
- Select Demo Database as your source and click Continue to proceed
- Select SQL Editor as your modeling method
- Paste the SQL query from above into the editor on the left side of the page
- Click Preview to execute the query
- Click Continue to proceed
- Give your model a name and unique slug (e.g., "Users in Nashville" and
- Select id as the primary key for your model
- Click Finish to create your model!
We just created a model using a SQL query that filters our
users table down to only those located in Nashville. Next, we'll configure our sync to add these users to a LaunchDarkly segment.
- Click on Syncs in the left sidebar
- Click on Add sync in the top right corner
- Select Users in Nashville as your model and click Continue to proceed
- Select LaunchDarkly Production as your destination and click Continue to proceed
- Select which LaunchDarkly project you want to sync data to
- Identify which field from your model represents the identifier known to LaunchDarkly
- Select Segment Included Users as the field you wish to update in LaunchDarkly
- Select Create a new segment
- Give a name to your segment (e.g., "My beta test")
- Click Continue to proceed to the last step
- Select Interval to tell your sync to run on a set interval
- Configure your sync schedule to run every 5 minutes
- Click Finish to create your sync!
Your LaunchDarkly sync configuration would look something like this.
And your sync schedule configuration would resemble this.
To date, our customers haven't experienced any errors while using the LaunchDarkly destination. (Knock on wood.)
Make sure you've configured your sync to use the correct LaunchDarkly environment! You might've accidentally pointed to a different environment. If that doesn't solve your issue, please reach out! We're happy to help.
Hightouch provides full visibility into the LaunchDarkly API calls made during each of your sync runs. We recommend reading our article on debugging tips and tricks.
Hightouch can alert you of any sync issues via Slack, PagerDuty, SMS, and/or email. For details, please visit our article on alerting.