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: "medium", discount: 5, purchaseButtonLabel: "Add to cart" }, data: { flags: { ads: true, checkout: "medium", discount: 5, purchaseButtonLabel: "Add to cart" }, resolvedVariantIds: { ads: "on", checkout: "off", discount: "on", purchaseButtonLabel: "1617982706033" }, visitor: { key: "wGP75VlKVPVf0uymf3UUu" } }, error: null, fetching: false, settled: true, visitorKey: "wGP75VlKVPVf0uymf3UUu" }

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