Best Practice #2: Beware of Switching from Anonymous to Logged-in State
When a user moves from an anonymous to a logged-in state, maintaining consistent feature‑flag behavior—such as discount eligibility—requires strategies like assigning a persistent visitor ID via cookies to link the two sessions and ensure a seamless experience.
When the same user transitions from an "anonymous" to a "logged-in" state, using feature flags presents a challenge: how to guarantee that the functionality experienced before and after login remains consistent.
For example, on many consumer platforms (e.g., e‑commerce sites), a visitor may see a 50% discount on a product that is controlled by a feature flag, add the item to the cart, and then log in to complete the purchase. The system must decide how to handle that discount after the login.
In B2C software, several strategies are available, and you need to choose the one that best fits your user‑experience goals.
If your application is primarily transactional and the consistency of feature flags across sessions is not critical, you might ignore the discrepancy. However, if your experiments involve pricing variations, maintaining consistency becomes essential, as you likely want the same price shown in every session for the same user.
When you deem flag consistency important, the technical solution is to create a visitor ID for each visitor and track it with a cookie, as illustrated below.
When the visitor logs in, immediately associate the visitor ID with the logged‑in user ID. It is advisable to set the cookie’s expiration to a semi‑permanent duration to ensure a consistent experience throughout the lifecycle of any feature flag.
Continuous Delivery 2.0
Tech and case studies on organizational management, team management, and engineering efficiency
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.