Targeting by Visitor Key

This demo is easiest to understand if you open its source code in a parallel tab.

Source code

This demo shows how to use @happykit/flags for targeting visitors.

HappyKit allows you to do percentage-based rollouts or A/B testing. To do this, HappyKit automatically creates a unique visitor key for every visitor and saves it as a cookie. You don't need to manage it yourself. The visitor key can not be passed in at all.

If you know more about the visitor, you can use configure your HappyKit Flags to use percentage-based rollouts or A/B testing based on the passed in user instead. HappyKit makes distinguishes users and visitors. You have control over the user HappyKit sees, but HappyKit controls the visitor.

Render #1 (Current render)
{ flags: { ads: true, checkout: "short", discount: 5, purchaseButtonLabel: "Get it" }, data: { flags: { ads: true, checkout: "short", discount: 5, purchaseButtonLabel: "Get it" }, visitor: { key: "kI4DfjFHJXNU4_3BBSC5N" } }, error: null, fetching: false, settled: true, visitorKey: "kI4DfjFHJXNU4_3BBSC5N" }

Note that aside from visitors, HappyKit also has the concepts of a user and traits. These three concepts are all independent of each other.