Incrementality testing: How to measure the true lift of a change

Your renewal reminder gets credit for 800 purchases. The team wants to send twice as many messages next month. Before approving the spend, ask how many of those customers would have purchased without the reminder. A message that reaches someone just before a planned purchase can receive attribution even when it changes nothing. A message that persuades someone to purchase in the app a week later may create value without getting the last click.
Incrementality testing estimates the additional outcomes caused by an intervention relative to an explicit alternative. The intervention can be an ad campaign, a free-shipping policy, a renewal reminder, or a product feature. The alternative can be no campaign, the existing product, or a different allocation of budget. The effect belongs to the comparison you actually ran. “Run the campaign versus stay silent” and “move the same budget from display to search” are different tests.
Define the counterfactual before setting up the holdout
An attribution model allocates credit for observed outcomes across recorded touchpoints. It can help you understand which paths appeared before purchases. Incrementality asks what would have happened under a different policy. Comparing buyers who clicked with people who did not click usually entangles the effect of the campaign with intent to buy. The order of touchpoints does not fix that problem. In field experiments comparing advertising measurement methods, observational estimates could differ materially from randomized estimates even when detailed data were available.
Write the decision from the perspective of whoever controls the budget or release. For a grocery retailer: “Should we offer free delivery to lapsed households for one week, given the cost and the risk that they simply move next week's order forward?” That sentence identifies an eligible audience, a specific treatment, and a plausible reason a short-term sales lift might overstate the economic value. Now specify what a control household can still receive. If routine loyalty messages and scheduled offers continue, the study measures the extra offer on top of those existing policies.
Choose a unit you can hold out and observe
A household may share an address, devices, and a loyalty account. Randomizing individual email addresses can leave one person in control while a family member redeems the offer on the same basket. If stable household assignment is feasible and the decision concerns household purchasing, use it for assignment and analysis. If you can identify only an account, state that boundary. Document the amount of expected leakage before deciding the test answers a household-level question.
Use an outcome source that observes both groups. The campaign platform can identify clicks on the offer but generally cannot establish whether a control household bought through an unrelated channel. A transaction ledger or reconciled set of order records may cover both subject to identity matching and permissions. Measure consent and match coverage independently. If one group produces customer IDs more often because the message signs people in, some of the apparent lift could be improved identification. Gross sales, net sales after refunds, and contribution margin each need their own documented definition.
Establish the assignment and observation calendars
Record when a unit becomes eligible, when it is assigned, how long it can receive the intervention, and how long its outcomes remain observable. A test that offers free delivery on Monday and counts sales through midnight will capture immediate redemptions. It will miss a customer who waits until Tuesday to order and may exaggerate growth if a household simply buys its regular Friday groceries early. Choose windows based on the normal repurchase cycle and the decision deadline. If shipping or refund costs arrive later, mark the revenue and margin readouts at different stages of maturity.
Scale the holdout to the information needed for a decision. A 1% holdout may protect sales volume in the short run but leave uncertainty large enough to justify almost any conclusion. Estimate eligible units, baseline outcome variation, and the minimum incremental gain that would pay for the policy. Revisit allocation before launch if the control group is too small. A plan for what a holdout measures should name the interventions it excludes. A persistent product holdout that misses several launches estimates their combined effects and interactions; it does not separately attribute the result to the latest banner.
Decide what to do with a negative estimate
Make room in the design for an intervention that reduces outcomes. A noisy reminder might prompt a customer to cancel. A discount could move a purchase into a lower-margin channel. An uplift-only dashboard that truncates negative values at zero cannot guide a fair funding decision. Plan to show both arm rates, the signed difference, and the uncertainty interval. Name one customer-cost guardrail, such as unsubscribe rate, and write down what would stop the intervention before the test reaches its planned end.
Measure a coupon’s incremental purchases with a randomized holdout
A grocer wants to send a $5 coupon to loyalty households that have gone eight weeks without a purchase. The CRM report can count people who click from the email and place an order. The budget decision asks how many more households will buy if the grocer runs the campaign. Some customers would return without a coupon, and others may see the message and shop in a store without clicking anything. A holdout makes both kinds of behavior visible in the comparison.
Randomize the opportunity before sending the message
Build the eligibility list once per household using purchase history available before the first send. Require a contactable household with permission for this campaign, and define which purchases the loyalty system can observe. Assign a stable household ID because members share a rewards account and can redeem the same offer. Randomizing two members separately could expose one control member through a treatment member before either buys anything.
Suppose 100,000 eligible households enter the test. Randomly assign 80,000 to the coupon policy and 20,000 to a holdout that gets the usual experience without this particular offer. The 80/20 allocation is illustrative. Before promising a detectable lift, plan precision for the smaller control arm. Save the eligibility time, assignment, campaign version, and whether the sending service attempted delivery. Log the scheduled opportunity in both arms so a silent holdout enters the data at the same moment as a recipient.
Count each assigned household once if it makes any qualifying purchase within 14 days. Use its first eligible opportunity as the start and allow the full window to elapse. Pull purchases from the same loyalty transaction records, including physical stores and digital orders that can be linked consistently. If redeeming the coupon prompts a cashier to scan the loyalty card, treatment purchases may be easier to link. Check identification rates using an independent transaction audit or restrict the primary outcome to a channel with consistent account identification. Label that narrower outcome explicitly. A trustworthy experiment design identifies the assignment unit, observation window, and outcome source before the first marketing report arrives.
Calculate lift on all assigned households
Suppose 4,400 treatment households and 1,000 control households buy within the window. Treatment's conversion rate is 4,400 / 80,000 = 5.5%. Control's rate is 1,000 / 20,000 = 5.0%. Subtracting the rates gives an absolute effect of 0.5 percentage points, or five additional purchasing households per 1,000 assigned to the campaign. Dividing the difference by the 5.0% control rate gives 10% relative lift. Each number needs its unit. “A 10% increase” alone is easy to mistake for ten additional buyers per hundred.
At the holdout's rate, 80,000 comparable households would produce an estimated 4,000 purchasers without the campaign. Treatment produced 4,400, so the estimate is 400 incremental purchasing households among the 80,000 assigned. Subtracting 1,000 from 4,400 would confound the effect with the arm sizes. Projecting the observed rate difference over all 100,000 eligible households gives 500 incremental purchasers for a comparable full send. That last figure is a projection and assumes the campaign's effect survives expansion.
Quantify the uncertainty as well. For this fixed-horizon illustration with independent household outcomes, an unadjusted large-sample 95% interval for the difference between two proportions is approximately +0.16 to +0.84 percentage points. The point estimate suggests five incremental buyers per thousand. Values closer to two or eight per thousand are also compatible with the observed data under that calculation. Use a method that matches the actual design if households were grouped by store or the team monitored a sequential decision rule.
Measure the outcome you changed
Choose a primary outcome and denominator that both treatment and holdout can report over the same time window.
Explore the KPI PlaybookDistinguish receipt, click attribution, and causal impact
Suppose 72,000 treatment messages were delivered and 18,000 households clicked. Keep all 80,000 assigned households in the primary treatment denominator. A bounced message is part of how the mailing policy performs. An open or click is a post-assignment action associated with interest. Comparing clickers with the entire control arm introduces a different selection mechanism on each side. Research on exposure opportunities in advertising experiments shows why estimating the effect among people who would actually be reached requires a design that identifies comparable opportunities.
The channel dashboard might attribute 2,000 purchases to the email. Those purchasers may include customers who were about to visit anyway. The experimental estimate of 400 is a group-level difference and cannot identify which 400 individuals bought because of the offer. The distinction matters beyond coupons. Randomized paid-search experiments at eBay found that people likely to click were already more likely to purchase, helping explain why conventional estimates differed from experimental returns.
Look for ways the offer crosses the holdout boundary
Bind redemption to the assigned loyalty household when the question concerns a household-specific offer. Before reading lift, count holdout accounts that received the campaign through a second email service, saw the same code in an app banner, or redeemed it at checkout. Reconcile those incidents with campaign logs. Removing contaminated controls after the fact would select on what happened after randomization. Disclose the leakage, assess whether the intended contrast still exists, and repair the delivery rules before a repeat if necessary.
If sharing is part of the proposed program, disabling it would test a different offer. Field experiments on shareable coupons illustrate that referrals can generate outcomes outside the original recipients. Consider a geographic or other group-level design when those spillovers are substantial. Also state which other promotions ran in both arms. A multi-feature holdout measures the cumulative experience it withholds. Withholding several campaigns together can answer a portfolio question, while isolating the contribution of this particular coupon requires the arms to differ on that offer.
Choose a holdout that can actually avoid the intervention
A local delivery marketplace wants to know whether an advertising campaign brings in additional completed orders. A banner ad promoting the marketplace can reach multiple members of the same household. Outdoor placements reach people who never signed in. Extra orders can also change courier availability and delivery times for nearby customers. Randomizing signed-in accounts would be easy to implement, but it would leave several routes by which control customers could experience the campaign or its effects.
Draw the routes from intervention to outcome before picking a unit. An individually randomized coupon delivered to a private inbox can support a customer-level test if it cannot readily be transferred and it doesn't change a shared constraint. A citywide campaign often calls for a geographic comparison. A dispatch rule shared by all active couriers in a market may suit a switchback design. The useful boundary is the one within which most of the intervention and its consequences remain.
Pair markets using information available before the campaign
Choose eligible markets before looking at campaign outcomes. Seek stable coverage for both spend and orders, enough local control over delivery of the ads, and a credible way to limit exposure in holdout markets. Remove areas that can't support the planned intervention, documenting why. Use historical order volume, seasonality, trends, and planned budgets to identify comparable pairs. Then, where feasible, randomly assign one market in each pair to treatment and the other to control. Matching on history alone leaves open the possibility that business decisions sent the campaign to markets already expected to grow.
Suppose you can operate in 16 eligible markets, forming eight pairs. A large number of individual orders does not create more than eight paired randomization decisions. Simulate assignments on historical periods without a campaign to estimate how noisy the proposed contrast is. Look for pairs dominated by a single festival, weather event, or supply constraint. Google's geo-experiment research describes using non-overlapping geographic regions to estimate advertising effects. Make the result's scope explicit if your eligible markets exclude rural areas or the largest cities.
Decide how you'll attribute orders to a region. A customer may see an ad near work and place an order at home. A courier can cross a city boundary. A media platform may target a region more broadly than its label suggests. Inspect delivered impressions and spend by geography, compare neighboring regions, and keep a record of campaigns running alongside yours. If the same national creative appears in both groups, your estimate concerns the additional regional campaign on top of that background. It cannot recover the effect of removing all advertising.
Switch treatment over time when participants share a system
A marketplace testing dispatch logic may have too few independent regions to leave half on the old rule for a month. In a switchback, a region runs one dispatch policy for an assigned block of time and another policy in other blocks. Randomize the schedule under a plan that balances time of day and day of week. Every busy Friday evening in treatment and every quiet Tuesday morning in control would confound the policy with demand. DoorDash's account of switchback analysis explains why outcomes must be analyzed in a way that respects the experiment's region-time units.
Estimate how long an action continues to affect the system. A courier dispatched at 5:55 may remain unavailable well into the 6:00 block. Excluding the first few minutes after a change can help if the carryover dissipates on that time scale. If positioning effects persist for hours, short blocks offer little clean contrast. Longer blocks leave fewer independent changes and may have worse precision. Research on switchback design formalizes the tradeoff. A lasting intervention, such as a brand campaign customers remember, is generally a poor candidate for rapid alternation.
Put the comparison and the follow-up on a calendar
Use a measurement calendar that the people buying ads, dispatching drivers, and reporting revenue can check. For an illustrative regional campaign, it might look like this.
- Before launch. Analyze several prior cycles, simulate placebo assignments, freeze the eligible regions and order definition, and inspect planned regional promotions. Choose the test duration from the expected effect, variation between markets, and the business calendar.
- During delivery. Keep the same market assignments, record actual spend and reach, and monitor operational harms. Investigate a broken placement or depleted local inventory as it happens. Keep an audit trail of any intervention that changes the contrast.
- After the final exposure. Maintain the agreed comparison through the outcome window if the question includes delayed orders. Distinguish an order placed during the campaign from one placed later by someone reached during it. Wait for cancellations and the reporting lag required by your definition of completed orders.
- At the readout. Report incremental orders with uncertainty, the markets and dates they cover, and any geography that failed to receive its assigned campaign. Keep a separate estimate for later demand displacement if the promotion may have pulled purchases forward.
The holdout's duration defines what you can learn. A one-week comparison can illuminate a short purchasing response. It is a weak basis for claiming a lasting change in customer habits. Similarly, a program-level holdout can capture the combined impact of several releases while leaving their individual contributions unresolved. Coordinate product and marketing experiments when both touch the same journey, so the comparison you preserve matches the question you're going to ask.
Decide what an incremental order is worth
A retailer is deciding whether to renew a paid reminder campaign. It randomly assigns 25,000 eligible customers to a group eligible for the ads and 25,000 to a holdout suppressed from this campaign. Both groups can buy through any channel. The primary outcome is whether a customer buys during the same follow-up window. Keep all assigned customers in their group, including those in the campaign arm who never receive an impression. That comparison measures the effect of buying the campaign under its actual delivery conditions.
Suppose 2,600 customers in treatment and 2,500 in control make a purchase. The conversion rates are 10.4% and 10.0%. The difference is 0.4 percentage points, a 4% relative lift. Applied to 25,000 treated customers, the estimated increment is 100 purchasers. You could observe 2,600 purchases in the treatment arm even if only a small fraction arose because of the reminder. Most of those customers would have purchased anyway, as the holdout helps establish. Randomized advertising field experiments illustrate why an association between seeing an ad and purchasing can misrepresent its causal effect.
Calculate incremental return and break-even spend
Keep the economics simple initially. Assume one order per purchaser and $50 in net revenue per order in both groups. The estimated incremental revenue is 100 × $50, or $5,000. If treatment required $2,500 more ad spend than control, incremental return on ad spend is $5,000 divided by $2,500, or 2.0×. An attribution report might credit 600 orders to the campaign and show $30,000 divided by $2,500, or 12× attributed ROAS. The larger figure measures credit under the attribution rule. It doesn't establish how much revenue the retailer would lose by canceling the campaign.
Now use the contribution margin the finance team recognizes. With 60% contribution margin before advertising, the estimated $5,000 of incremental revenue yields $3,000 toward campaign cost. Subtract the $2,500 and the estimated incremental contribution after advertising is $500. At that margin, the campaign needs $1 ÷ 0.60, or about $1.67 of incremental net revenue per dollar of spend, to break even. If treatment changes order values, return rates, discounts, or fulfillment costs, measure the resulting revenue or margin per assigned customer directly. Multiplying additional purchasers by the average value among buyers can miss those effects.
The example holds the spend difference fixed. In a regional bidding test, changing the campaign can also alter where the rest of a shared budget gets spent. Calculate the change in total spend for the comparison you designed. The research on incremental ROAS in paired geo experiments treats both incremental response and incremental spend explicitly. Counting every dollar in the treatment market while ignoring ordinary spending in the control market answers a different budgeting question.
Bring uncertainty into the funding decision
The observed $500 surplus is modest relative to the uncertainty in 100 additional purchasers. For this independent-user, fixed-horizon example, an approximate 95% interval for the difference in purchase rates is −0.13 to +0.93 percentage points. At the treatment group's size, that corresponds to roughly 33 fewer to 233 more purchasers. Under the same fixed $50 order value and $2,500 spend difference, the compatible incremental ROAS runs from about −0.65× to +4.65×. The 1.67× break-even level sits well inside that interval. Management cannot conclude from the point estimate alone that the next dollar will make money.
For a funding decision, put the tested audience, spend level, outcome window, expected contribution, and uncertainty on one page. The retailer might keep a capped campaign in the tested audience while designing a more precise follow-up, or direct the budget to an alternative with a clearer return. Increasing spend can reach less receptive customers or bid up the same inventory, so extrapolating the observed ratio to ten times the budget adds another assumption. Revisit the estimate after returns have settled and new-customer purchases can be distinguished from purchases pulled forward by the reminder.
Fund the next unit of spend using the comparison you tested
Bring the decision maker the observed incremental outcome per eligible unit, the uncertainty around it, the cost difference between policies, and the range of customers represented. Describe where rollout economics could change. Doubling an ad budget may reach a less receptive audience or change auction prices. Extending a coupon to frequent buyers may pay discounts to many households that would have purchased anyway. An effect measured at one intensity is evidence for that policy at that scale.
For product changes, an experimentation platform can connect assignment records to downstream warehouse outcomes such as renewals, refunds, or customer support contacts. Use the same discipline whether the intervention is a UI change or a campaign. Define the alternative, give both groups a comparable chance to have an outcome observed, and let the uncertainty and economics guide how far the next rollout goes.
Measure a change against a holdout
Try a controlled experiment in GrowthBook with a business outcome your team can trace to its source.
Start Measuring LiftRelated Articles
A magazine's home page shows two recent issues. The design team wants subscribers to try a shelf with four. All four covers are public, and changing editions while the page is open should update the shelf immediately. That gives you a small React feature with a useful acceptance test. Click from guest to subscriber and back, and count the covers each time.
We'll put the display limit in a typed local flag, evaluate it inside a React component, and leave the choice of edition with the app. The example runs in a client-rendered React app without a GrowthBook account, an SDK key, or a request for flag rules. For the wider workflow, free feature flags for coding agents explains what to ask an agent to implement and how to review the result.
Define what one flag controls
Start with an existing React and TypeScript app, or create a Vite React project for the example. Install both GrowthBook packages so the definitions and the hooks resolve against compatible SDK versions.
Create src/flags.ts. Here the feature value is a number, which lets the component use the same rendering code for either edition. A future change from four covers to three is one edit to the rule.
A guest falls through to the default of two. A subscriber matches the rule and gets four. This rule applies to every subscriber, so the ID has no effect on the result here. If you later roll the shelf out to a percentage of subscribers, you already have an identity to use for repeatable assignment.
The type registration release note explains the version requirement for LocalFeatures. The registration connects the definition, the attributes, and the value returned by the hook. For the TypeScript mechanics, see Jeremy Dorn's Register pattern walkthrough.
Put the current reader above the shelf
Replace src/App.tsx with the component below. The edition switch is a local fixture so anyone reviewing the change can reproduce both states. In an existing app, take those two values from the active reader in your session layer.
The provider receives an instance initialized with the current reader and the checked-in rules. React can render the correct shelf on the first pass for that reader. If the app is still loading a session, decide what should occupy the shelf in the meantime. For this public list a two-cover guest view is reasonable. On a page where a switch would interrupt the reader, wait for the session before mounting the shelf.
Give your agent the React setup
Use the local flags guide to ask for a typed definition, a provider with the current reader, and a test that changes the edition.
Open the Agent GuideThe useMemo dependencies include the ID and the edition. If a reader subscribes while signed in, their ID can stay the same while their edition changes. Depending only on the ID would leave the old SDK instance in place. Passing a fresh object as the dependency on every render would create unnecessary instances. The example uses the two primitive values the rule setup actually needs.
Read the numeric flag where React renders the list
Create src/IssueShelf.tsx. Keep one stable ID per issue and let the component use the resolved value to select how many items to render.
Keep the hook at the top of the component, inside the provider's subtree. The React SDK supplies the flag value through that provider. Calling a hook inside a click handler or inside the list loop would break the Rules of Hooks. Use the returned number in ordinary render logic.
There are two places you can see the number two in this implementation. The definition's defaultValue is what an ordinary guest gets through evaluation. The 2 passed to the hook is a fallback for a value the SDK can't supply. Giving them the same value makes the basic shelf a sensible fallback, but checking only the guest case would let a broken provider arrangement or missing definition go unnoticed. The subscriber case proves that the component actually received the rule.
The list keys identify magazine issues. Keep those keys independent of the flag. Switching from two covers to four should preserve the identity of the first two rows. There's also no need to remount the whole app with an edition-specific key. React preserves state according to component position and keys. For example, a search input outside the shelf shouldn't lose its text because someone subscribed.
Check the transition in both directions
Use the template's build script to type-check and bundle the app. Once that passes, start the dev server and open the local address it prints.
On first load, the page says guest and lists November and October. Click Switch edition. The same page should say subscriber and add September and August. Click again. The list should return to the original two issues, in order. This last check catches code that appends more results on upgrade and never removes them on downgrade.
For a compile-time check, temporarily replace the numeric fallback with the string "2". Run the build again and inspect the error on the hook call. Then restore 2 and rebuild. If the string compiles, check that src/flags.ts belongs to the same TypeScript project as the component and that the package manager resolved compatible core and React versions.
Look for the core package used by your app and by the wrapper. If the app has several incompatible installations, align the versions before diagnosing the JSX. A team using an existing build script should also confirm it actually runs the TypeScript checker.
Hand off a React change someone can review
Give your coding agent the one-shot local feature flags guide and a short description of the observable behavior. For this shelf, the request can be as specific as the test.
The shelf controls how many public titles to display. If your actual feature unlocks paid articles, enforce access when the server serves an article. A client-rendered flag only decides what to show in that browser. Whenever a change to the display limit can wait for a deployment, the small local file keeps the decision reviewable alongside the component. When an editor needs to change it between issues without an engineering release, compare the free GrowthBook options for managing flag rules.
Manage the shelf in GrowthBook
Start a GrowthBook workspace when your magazine team is ready to manage shelf rules between deployments.
Get Started with GrowthBookTwo customers download the same weekly report. One has agreed to preview a new CSV column. The other feeds the old two-column format into an importer. Both requests can land on the same Node.js process, and each needs the right file even if the other request arrives while the report is loading.
This tutorial builds that endpoint with one checked-in feature flag. The process loads the rules once. Each request supplies its own workspace attributes and receives its own evaluation. You can run the whole example on your machine without an account, a client key, or a flag server. The free feature flags for coding agents walkthrough introduces the local approach. Here we'll give the agent a server-specific test to pass.
Set up a small TypeScript service
Use Node.js 22 or newer for this example. In an empty directory, create an npm project that uses ES modules, install the core SDK, and add the TypeScript tools.
Create tsconfig.json at the project root. The sample runs TypeScript directly with tsx and checks types in a separate step. Type checking with tsx explains why the two commands serve different purposes.
The following files all live next to that configuration. The server imports ./flags.js even though the source file is flags.ts. That spelling follows TypeScript's Node.js module resolution for ESM and works with this runner.
Define the report contract in one flag
Create flags.ts. The public format has two columns. The sample preview workspace gets one additional column. The only targeting attribute the rule needs today is reportPreview. Carry the workspace ID too, so two people downloading a report on behalf of the same workspace can share an assignment if you introduce a percentage rollout later.
The SDK type registration update covers this rule syntax and the 2.2.0 minimum. If you misspell reportPreview in a condition or use a string where the boolean flag expects a value, TypeScript can point at the definition. The Register pattern also makes the same feature name available in other modules without threading a generic type through each handler.
Before you add the endpoint, decide what belongs to the process and what belongs to the request. The feature definitions are identical for both customers. Their identity and preview enrollment can differ. If a handler changes an attribute on a single shared user instance before awaiting a database query, another handler could replace that attribute before the first handler resumes.
Give your agent a server-side task
Use the one-shot guide to add checked-in rules. Ask your agent to keep workspace attributes local to each request and demonstrate both CSV formats.
Open the Local Flags GuideCreate a scope when the request arrives
Create server.ts. The Node.js SDK provides GrowthBookClient for the process and createScopedInstance for the current request. The two fixture paths below stand in for two authenticated workspaces. The server binds to the loopback address so you can exercise it locally.
The HTTP handler looks up a workspace, creates its scope, and holds that scope across an asynchronous operation. The short promise-based timer gives a second request time to arrive. In a real export, that's where the database or storage read would happen. Keep the stable client at module scope and the scoped instance inside the handler. If a formatter needs the decision, pass it the boolean or the scoped instance.
In production, resolve the workspace and its access rights from the authenticated session before reading the report. The two selectable paths here are fixtures for public sample data. A caller's choice of a header, query string, or workspace slug can't establish permission to read another customer's report. The endpoint also prevents shared response caching. If you cache real exports, the cache needs to distinguish the workspace and the report format, along with any other inputs that change the response.
Test two requests that overlap
In the first terminal, type-check the service and start it. A successful type check exits quietly. The next command prints the loopback address and keeps the server running.
Save the following as verify.mjs. In a second terminal, run node verify.mjs. Node's built-in fetch calls the local server. Strict assertions compare the full header and data row, including where each row ends.
You should see the single success line. Testing just the preview workspace proves that the code can add a column. Testing both responses catches the more expensive mistake of silently changing an existing customer's export. Keeping the old format assertion around is especially valuable when the downstream importer belongs to someone outside your team.
To check the compile-time boundary, temporarily change gb.isOn("includeUniqueReaders") to gb.isOn("includeUniqueReader") and rerun npx tsc --noEmit. The diagnostic should identify the misspelled key. Restore it before running the server again. A coding agent can include the before-and-after type check and the two CSV headers in its pull request.
Decide when to expand the report
When one preview customer is ready, leave everyone else on the default. If the next step is to enroll a fraction of workspaces, choose an attribute that matches the promise you're making. Hashing a workspace ID lets colleagues downloading the same report share a format. Hashing each user's ID could give two analysts in the same company different column sets. The one-shot guide shows how to express a percentage and hash attribute in a local rule.
A new rule in flags.ts reaches a process through your deployment. During a rolling deploy, the same workspace might hit old and new processes. If customers need a durable choice of export schema, keep supporting the agreed format in the API itself. When the operational requirement is to change targeting between deploys, you can keep the scoped evaluation in the handler and change how the process receives its rules. The free GrowthBook offerings overview covers Cloud Starter and self-hosting for teams that want to manage those rules.
Manage report targeting in Cloud
Create a GrowthBook workspace when the team supporting exports needs to expand the preview independently of a server release.
Get Started with GrowthBookYour conference agenda has a new “Show room” button. Reviewers should see it on the first page load. Everyone else should get the existing agenda. If a Server Component renders the old agenda and a browser hook independently decides to show the new button, the first HTML and the browser can disagree.
In the Next.js App Router, the server can make this decision once and pass a boolean to the interactive component. We'll define the flag in the repo, select the preview audience with a local test cookie, and verify the actual HTML for both visitors. Clicking the button will still work after hydration. You can follow along without a GrowthBook account or client key. If you're assigning this work to an agent, the free feature flags for coding agents walkthrough gives the background.
Keep the flag definitions on the server
Use a TypeScript App Router project, or create a small one with create-next-app. These paths assume the project has an app directory at its root. If yours uses src/app, put both app and lib under src so the relative imports still match.
Keep the starter's root layout. Create lib/agenda-flags.ts with the following code. The SDK type registration update explains how LocalFeatures checks the flag and its rule against the registered types. This setup requires version 2.2.0 or later.
The module can reuse the client and rules across requests handled by the same process. It only holds the current visitor's audience inside the function call. Two requests can therefore use the same flag file and get different results. The Node.js SDK documents the scoped client used under the App Router here.
This particular rule has no percentage and needs no visitor ID. The two audiences are sufficient. If the team later asks for a rollout to 10% of attendees, add a stable attendee or registration ID and choose which of those units should stay together. Jeremy Dorn's Register pattern article explains how a change to an attribute type reaches the call sites that construct it.
Read the cookie for this request
Create app/agenda/page.tsx. The static heading can render for everyone. The request-specific content sits behind a Suspense boundary, so the fallback can show a neutral loading message until the server has the cookie.
The App Router's cookies function reads the incoming request asynchronously. Read it inside the visitor-specific component. Keeping that read out of shared cached code lets the surrounding page reuse common content without treating one visitor's decision as another's. This placement also accommodates App Router projects using Cache Components.
Give your agent the Next.js setup
Use the local flags guide with a concrete request to evaluate one flag on the server and return the same decision to the browser.
Open the Local Flags GuideThe cookie in this demo is a convenient way to preview a public UI treatment. Anyone with that cookie can see the room label. To target paying attendees or private sessions, obtain the audience from the verified session on the server and authorize the underlying data separately.
Pass one decision to the interactive component
Create app/agenda/Agenda.tsx. It's a Client Component because a visitor can open and close the room details. Its initial branch comes directly from the boolean supplied by the page.
The client boundary takes a serializable prop. The component receives true or false. The SDK instance, targeting rules, and cookie handling stay in the server module. You don't need a React provider for this component because its only browser-side choice is whether the visitor has clicked the button.
Follow one page load through server rendering and hydration. For a preview visitor, the server can send a section with a “Show room” button. React's first client render gets the same showRoom value and starts with open set to false. Hydration attaches the click handler. Opening the room detail then updates component state and doesn't require another flag evaluation.
Verify the HTML and the click separately
Build the production app and start it on port 3100.
In a second terminal, save this as verify-agenda.mjs in the project root and run node verify-agenda.mjs. The test makes two requests to the same route and looks for a marker on the rendered section. A marker in the HTML helps catch an implementation that only adds the intended layout after JavaScript runs.
Now open http://localhost:3100/agenda in a fresh browser profile. You should see the session title without a room button. In that local page's browser console, set the demo cookie and reload.
Click Show room and look for Room 204. Click Hide room and the room should disappear. This second check proves the component became interactive. If the server response test passes but the click fails, inspect the browser console for a hydration error before changing the flag rules.
Remove the fixture and reload once more. The button should disappear and the agenda title should remain.
The reload is deliberate. Editing the cookie in an already open document doesn't rerun its Server Component. In your app, use the normal session-change flow to request a fresh server render when a visitor signs in, signs out, or leaves a preview group.
Choose where the next flag should be evaluated
For a decision needed in the initial HTML, give the agent an observable requirement. Ask it to show the two HTTP responses, then click the interactive control in the preview. The first check catches an incorrect layout. The second catches correct HTML that never becomes interactive.
If a later feature depends on an action entirely within the browser, evaluate whether its flag belongs in the client tree. The one-shot local flags guide covers both placements. This agenda only needs one server decision. Updating its checked-in rule takes a deployment. Keep that tradeoff in view if the event organizer needs to pause a preview while attendees are already arriving. For that case, compare GrowthBook’s free options for changing flags between deploys.
Manage the agenda rollout in Cloud
Create a GrowthBook workspace when the organizer needs to adjust a preview audience while your Next.js app is serving attendees.
Get Started with GrowthBookReady to ship faster?
No credit card required. Start with feature flags, experimentation, and product analytics—free.




