Tutorials
Using LaunchDarkly with Knock to A/B test messaging

Using LaunchDarkly with Knock to A/B test messaging

Learn how to use LaunchDarkly with Knock to A/B test messaging workflows and templates.

In this tutorial we'll walk through how to use LaunchDarkly segments and experiments to power A/B testing across Knock's cross-channel messaging.

Overview

#

A/B testing your messaging can improve engagement rates, conversion, and user experience. By testing different message variants, channels, timing, and targeting, you can optimize your notification strategy based on real user behavior data.

This tutorial shows you how to combine LaunchDarkly's feature flags and experimentation platform with Knock's notification infrastructure to run A/B tests on your workflow messaging.

What you'll learn:

  • How to use LaunchDarkly flags to control message variants
  • How to leverage LaunchDarkly segments for targeted messaging experiments
  • How to implement A/B testing logic in Knock workflows using branch steps
  • How to measure and analyze messaging experiment results
  • Best practices for messaging experimentation

Integration architecture

#

The LaunchDarkly + Knock integration follows this flow:

  1. LaunchDarkly defines your experiment parameters (flags, segments, variations) and manages statistical analysis.
  2. Your application evaluates flags and passes results to Knock via trigger data.
  3. Knock workflows use branch steps to deliver different messaging experiences based on flag variations.
  4. Knock captures engagement events (message delivery, opens, clicks) and forwards them to LaunchDarkly.
  5. LaunchDarkly correlates engagement events with flag variations to measure experiment success and statistical significance.

LaunchDarkly concepts and setup

#

Flags

#

LaunchDarkly Flags serve as the control mechanism for your messaging experiments. They determine which message variant each user receives.

We'll be using the example flag below in our tutorial. You could also create multi-variant flags to run more complex experiments with different message content, channels, and timing.

Simple A/B test flag:

  • Key: messaging-AB-test
  • Variations: control, treatment
  • Default: control

Segments

#

LaunchDarkly Segments enable you to define test populations and ensure consistent user experiences across multiple flags.

Experiments

#

LaunchDarkly experiments connect your messaging flags to business metrics, enabling you to measure the effectiveness of different messaging strategies.

Using LaunchDarkly with Knock workflows

#

You can use LaunchDarkly with Knock workflows to orchestrate different cross-channel messaging experiences based on the flags and experiments you've defined in LaunchDarkly. We'll cover two methods for using LaunchDarkly with Knock workflows: flag-controlled workflow selection and branch-based message variants.

Method 1: Flag-controlled workflow selection

#

This approach uses LaunchDarkly flags to determine which Knock workflow to trigger, enabling you to test different notification strategies. You can use this approach to test different messaging approaches, compare email vs. SMS vs. push notification strategies, or test different workflow timing and sequences.

1

Evaluate flag in your application

First, evaluate the LaunchDarkly flag in your application.

2

Trigger appropriate workflow

Next, trigger the appropriate Knock workflow based on the flag value.

Method 2: Branch-based message variants

#

This approach uses a single workflow with branch steps to deliver different messaging experiences based on LaunchDarkly data passed via trigger data. You can use this approach to A/B test different templates within the same workflow, personalize message content based on user segments, or run other kinds of flag-based experiments.

1

Evaluate flags and pass to Knock

First, evaluate the LaunchDarkly flags in your application and pass the results to Knock via trigger data.

2

Configure branch step in Knock workflow

In your Knock workflow, add a branch step with these conditions:

  • Control branch: data.user_ab_test_variation == "control"
  • Treatment branch: data.user_ab_test_variation == "treatment"
  • Default branch: Fallback for any unmatched conditions

Analytics and analyzing results

#

To measure messaging experiment success, forward Knock's engagement events to LaunchDarkly. This allows LaunchDarkly to correlate message engagement with flag variations and calculate proper conversion rates.

Three integration approaches are available:

  1. Direct webhook integration. Forward events in real-time via Knock's outbound webhooks.
  2. Segment integration. Use Knock's Segment extension to route events through Segment to LaunchDarkly.
  3. Data warehouse integration. Use Knock's warehouse sync to bring data into your warehouse for analysis.

Method 1: Direct webhook integration

#

Set up a webhook endpoint to receive Knock events and forward them to LaunchDarkly.

1

Create webhook endpoint

Create an endpoint to receive Knock webhook events and forward them to LaunchDarkly:

2

Configure webhook in Knock

In your Knock dashboard:

  1. Go to Developer → Webhooks
  2. Add your webhook endpoint URL
  3. Select events: message.read, message.link_clicked
  4. Enable webhook

Learn more about outbound webhooks.

Method 2: Segment integration

#

Use Knock's Segment extension to automatically forward events through Segment to LaunchDarkly.

1

Configure Segment extension

Configure the Segment extension in your Knock dashboard with your Segment write key. Knock will automatically forward engagement events to Segment.

2

Set up Segment to LaunchDarkly connection

In your Segment dashboard:

  1. Add LaunchDarkly as a destination.
  2. Configure event mapping from Knock events to LaunchDarkly metrics.
  3. Map events like Notification read → email_opened in LaunchDarkly.

Method 3: Data warehouse integration

#

For comprehensive analytics, combine Knock's data warehouse sync with LaunchDarkly's data export.

1

Enable Knock warehouse sync

Configure warehouse sync to your data warehouse. This provides detailed message and engagement data.

2

Export LaunchDarkly experiment data

Use LaunchDarkly's data export to get flag variation data in your warehouse, then join with Knock's engagement data for analysis.

Implementation example: welcome email A/B test

#

This example shows a complete implementation of A/B testing welcome emails with different messaging styles.

1

LaunchDarkly setup

First, create the flag and experiment in LaunchDarkly.

Create flag in LaunchDarkly:

Set up experiment:

Create metrics for the experiment:

2

Application integration

Integrate the LaunchDarkly flag evaluation into your user registration flow.

3

Knock workflow configuration

Create a workflow with branch steps and configure email templates for each variant.

Create workflow with branch step:

  • Workflow key: welcome-sequence
  • Add branch step with conditions:
    • Friendly branch: data.email_style == "friendly"
    • Professional branch: data.email_style == "professional"
    • Casual branch: data.email_style == "casual"

Configure email templates for each variant.

4

Tracking and analytics

Set up conversion tracking and monitor experiment results.

Set up conversion tracking: