How much does my search, my reviews or my free delivery threshold really earn?
TL;DR
Difficulty: Advanced
The revenue a report credits to a feature is not what the feature earned, because the people who use it would often buy anyway.
- Measure a part by switching it off for a random share of visitors and comparing contribution per visitor.
- Calculate the smallest detectable effect first: at about 2,000 orders a month only parts worth around 15% or more can be measured alone in eight weeks.
- Trigger on the visitors who could see the part, bundle small parts, and use switchbacks for delivery charges.
- On your own code it is a flag, an exposure table and one SQL query.
- Keep every result, with its interval and cost, in a feature value register and decide with the interval.
Your analytics say search brought in €61,000 last month. Some of those customers would have bought anyway, and the report cannot tell you how many. This chapter shows how to measure what each part of a shop really earns, how large a shop has to be before a test can see it, and how to build the switch, the logging and the analysis on Rails and Solidus.
Your reports say what a feature touched, not what it earned
Sooner or later every shop owner wonders what one part of the shop is really worth: the site search, the reviews, the "customers also bought" row, the free delivery rule, the live chat. Which ones would you miss if they disappeared tomorrow?
Analytics tools answer a different question. They tell you how much revenue passed through a feature: orders from sessions that used search, revenue from clicks on recommendations. That number is real, but it is not what the feature earned. Many of those customers would have bought anyway.
This chapter shows how to measure what each part of a shop is worth on its own. The method is simple to say and careful to do: switch the part off for a random share of visitors, and compare what the two groups leave behind in contribution. Along the way you will see why most small effects cannot be measured at all at a typical shop's size, what to do about that, how to build the switch and the logging on Rails and Solidus, and how to keep a register of what every part earns and costs.
It builds on two earlier chapters. Why a shop should be one application explains why owning the code matters, and cohort analysis explains how to follow groups of customers over time, which is exactly what a test does.
Example: Niamh's question about search
Shannonside Home is the invented homeware shop in Limerick that runs through this series (shannonsidehome.example). Niamh owns it, Callum is her developer. The shop sells ceramics, kitchen textiles, lamps and small furniture, about 1,400 products. Its monthly baseline: 110,000 sessions, a conversion rate of 1.8%, so 1,980 orders, an average order value of €84 including VAT, a gross margin of 52% on product, and a contribution before marketing of €44,440, which is €22.44 per order. For this chapter one more invented figure: those 110,000 sessions come from about 74,000 different visitors a month.
Niamh's analytics show that sessions with a search placed 726 orders last month. At €84 each that is €60,984 of revenue "from search", and at €22.44 each, €16,291 of contribution. A search server upgrade would cost money, and Niamh wants to know whether search is worth investing in. Is it worth €16,291 a month? Every figure about Shannonside Home in this chapter is invented for the example.
Revenue from a feature is not what the feature earned
The search report counts the orders of people who used search. It does not count the orders search caused. The difference is selection bias: the people who use a feature are not a random sample of visitors. People who search often arrive knowing what they want, so they would buy at a high rate with or without the box. The chapter on site search shows why searchers convert better and why part of that belongs to the person, not the tool.
The same is true of almost every feature. People who read reviews are already considering a product, and people who use a wishlist are already planning to come back.
How big is the gap? Two well known studies give a sense of it. Sharma, Hofman and Watts studied recommendations on a large online retailer and found that although recommendation clicks made up a large share of traffic to the products they examined, at least 75% of that activity would likely have happened without the recommendations1. Blake, Nosko and Tadelis ran large field experiments at eBay and found that the returns from paid search ads were a fraction of what the usual non experimental estimates claimed. Brand keyword ads had no measurable short term benefit at all2. Different features, same lesson: the number that passes through a feature can be several times what it adds.
Example: who are Shannonside's 726 search orders?
Picture three kinds of customer among the 726.
- Some knew exactly what they wanted ("oval linen tablecloth"), typed it, and bought. Without search, most of them would have found it through the menu, a little slower.
- Some were unsure, searched, found something they would not have found otherwise, and bought. Search caused these orders.
- Some searched, found nothing useful, browsed, and bought something else. Search did nothing for them, but the report still counts them because the session contained a search.
The report credits all 726 orders to search. Only the second group is what search earned. Nobody can tell from the data which customer was which. That is why the rest of this chapter compares groups, not customers.
The question to ask: what would have happened without it?
The value of a feature is the difference between two worlds: the shop as it is, and the same shop, at the same time, with the same visitors, without that feature. Statisticians call the second world the counterfactual. You can never observe it for the same person, because each visitor lives in only one world. But you can observe it for a group, if the two groups are alike in every way except the feature.
The difference is the uplift, here measured as the relative change in contribution per visitor:
where is the uplift, is the average contribution per visitor in the group that sees the feature, and is the average contribution per visitor in the group that does not. The ratio is explained in Foundations: ratios and rates.
Example: uplift for two invented groups
Suppose 1,000 visitors see search and leave €600 of contribution behind, and 1,000 comparable visitors without search leave €520. Then and , so
Here and are the two groups' euro per visitor, and is the uplift.
Search adds about 15% to contribution per visitor, compared with a shop without it. The rest of the chapter is about making sure the two groups really are comparable, and about knowing how far to trust a number like 15% when the groups are of a realistic size.
Why before and after comparisons mislead
The obvious shortcut is to switch the feature off for a month and compare that month with the one before. It does not work, because everything else changes too. Season, weather, ad spend, a newsletter, a competitor's sale, a delivery strike. Kohavi, Tang and Xu, in the standard book on online experiments, treat comparisons over time as observational studies with a lower level of trust than a randomised experiment, and list the pitfalls in detail3.
Example: switching search off in January
Suppose Niamh switches search off for all of January and compares January's contribution with December's. December's contribution was higher, as it always is in a homeware shop before Christmas. The fall from December to January would be blamed on search. Now suppose she compares with last January instead. Ad spend was €2,000 a month lower last year, and a large furniture range was added in the spring. Again the difference mixes search with everything else. There is no month that is "the same except for search". There is only a group that is the same except for search, and a random split is the way to build one.
The holdout: switch the part off for a random share of visitors
A holdout test splits visitors at random into two groups. The larger group keeps the shop as it is. The smaller group, the holdout, gets the shop without the part being measured. Because the split is random, the two groups have the same mix of searchers and browsers, new and returning customers, phone and desktop users, and the same weather and ad spend at the same moment. The only systematic difference is the part. A holdout is an A/B test where the B is "without".
Three rules make it work:
- Randomise by visitor, not by page view. A visitor who sees search on Monday and no search on Tuesday is in neither group. The assignment must stick.
- Decide the assignment before the visitor can influence it. Assign on arrival, not when someone clicks into the search box, or the people who are most eager to search decide which group they belong to.
- Count everyone who was assigned, including those who never used the feature. A visitor who never searched still belongs to the group, because in the holdout you cannot know who would have searched.
The usual way to make an assignment stick without storing a list is deterministic hashing: turn the visitor's identifier and the name of the test into a number, and put the visitor in a group based on that number. The same visitor always gets the same number, so always the same group. Different tests use different names, so a visitor's group in one test says nothing about the group in another.
Example: one visitor, two tests
A visitor arrives with the identifier q7RbN2xYk4TzW1. Callum's shop runs two tests: search is on for 80% of visitors, reviews are on for 50%. The feature flag library he uses, Flipper, joins the test name and the visitor identifier, computes a CRC32 checksum, takes the remainder after dividing by 100,000, and switches the feature on if that remainder is below the percentage times 1,0004.
For search the text is site_searchVisitor;q7RbN2xYk4TzW1. Its CRC32 value is 3,511,036,797, and the remainder after dividing by 100,000 is 36,797. That is below , so this visitor sees search. For reviews the text is reviewsVisitor;q7RbN2xYk4TzW1, the CRC32 value is 846,596,447 and the remainder is 96,447. That is not below , so this visitor is in the reviews holdout. On every later visit the same arithmetic gives the same answers.
Choose one number to decide by: contribution per visitor
A test needs one main metric, decided before it starts, so that nobody can pick the metric that happens to look best afterwards. Kohavi and colleagues call this the overall evaluation criterion, and stress that it should be measurable during the test and believed to drive long term value5. For a shop the right one is contribution per visitor: contribution before marketing, from all orders the visitor placed during the test, averaged over every visitor in the group, including the many who bought nothing.
where is contribution per visitor in a group, is the number of visitors assigned to that group, and is the contribution of all orders placed by visitor during the test, zero for a visitor who bought nothing. This is an ordinary mean, see Foundations: mean.
Why not the usual numbers?
- Conversion rate ignores order size and margin. A free delivery rule can raise conversion and still lose money.
- Average order value ignores how many people buy. A higher threshold can lift it while fewer people order.
- Revenue per visitor ignores margin, delivery cost and returns. A feature that pushes heavy, low margin furniture can lift revenue and lower profit.
Contribution per visitor combines all of them. Contribution itself is worked out per order in the unit economics chapter.
Example: Shannonside's contribution per visitor
Not every visitor can be in a test (the consent section below explains why). Shannonside's tests include the visitors who agreed to analytics cookies, about 64% of them. Over the last eight weeks that group had 80,000 visitors, who placed 2,330 orders at an average contribution of €22.44. So
Here visitors, euro of contribution, and euro per visitor.
About 65 cent per visitor. It looks tiny, and that is normal: 97 of every 100 visitors buy nothing in eight weeks and count as zero. The figure is still the one that moves when a part of the shop earns money.
Guardrails: what must not get worse
A guardrail is a number that is not the goal but must not get worse. It catches a main metric that rises for a bad reason, or a test that breaks something nobody was watching. Write guardrails down before the test, with the change that would stop it.
Example: the guardrails for the search holdout
| Guardrail | Why it matters | Stop if |
|---|---|---|
| Share of visitors in each group | A split that drifts from 80/20 means the assignment is broken | Outside 79.5% to 80.5% after a week |
| Return rate of orders | A feature can raise sales of things people send back | More than 1.5 points higher in either group |
| Contacts to customer service per 1,000 visitors | People who cannot find a product write in | More than 20% higher in the holdout |
| Page load time at the 75th percentile | The new code must not slow the shop | More than 200 milliseconds slower |
| Repeat order rate after 60 days | A part can earn today and cost loyalty later | Checked after the test, recorded in the register |
The first row is the most important, and the least expensive to check. If 80% of visitors were meant to see search and the logs say 77%, something is assigning visitors wrongly (a cache serving one version to everyone, a bot hitting one group). No result from such a test can be trusted. The chapter on experiments inside your own shop shows how to test this formally with a sample ratio mismatch check.
How long and how many visitors: the smallest effect you can see
Before running a test, work out the smallest effect it could reliably detect. This is the minimum detectable effect. If the part you want to measure is probably worth less than that, the test will almost certainly end with "cannot tell", and the weeks of holding the part back are wasted.
where is the minimum detectable effect in euro per visitor, for a 5% false alarm rate, for an 80% chance of detecting a real effect of that size, is the standard deviation of contribution per visitor, and and are the numbers of visitors in the two groups. The ideas behind it are in Foundations: sample size and Foundations: spread.
The difficult number is . Contribution per visitor is mostly zeros with an occasional order, which makes it very spread out. If a share of visitors buys, and orders have an average contribution with standard deviation , then
where is the variance of contribution per visitor, is the share of visitors who order, is the average contribution per order and its standard deviation. The first term is the average of the squared values (only buyers contribute to it), the second is the square of the mean. See Foundations: spread.
Example: what an eight week test can see at Shannonside
Callum takes the last eight weeks: , , and from the order history (some orders lose money, a sideboard earns a lot). So
and . With a 50/50 split over eight weeks, each group has 40,000 visitors:
Here , , and euro per visitor.
About 10 cent per visitor, which is 15.5% of the 65 cent baseline. An eight week test at Shannonside can only reliably see a part that changes contribution per visitor by about 15% or more. That is a sobering number. Search might clear it. A wishlist will not come close.
Longer tests help, but more slowly than you might hope, for two reasons: the interval shrinks with the square root of the number of visitors, and returning visitors mean each new week adds fewer new people. Shannonside's test population grows by about 17,000 visitors in the first week and about 9,000 new visitors in each week after.
This is the honest headline of the chapter for a shop of Shannonside's size: you can measure the big parts, and you cannot measure the small ones one by one. The article on how much data you actually need shows the same arithmetic for ads and forecasts. Shops with ten times the traffic can see effects about three times smaller, because the interval shrinks with the square root.
The size of the holdout, and what the test costs
A 50/50 split measures fastest, but it also withholds the part from half your visitors. If the part is valuable, that costs real money while the test runs. A smaller holdout costs less per week and needs more weeks. The term shows the trade: with visitors and a holdout share , it equals , which is for and for . A 20% holdout needs about 56% more visitors for the same precision.
Example: two ways to test search
Suppose search is really worth about €5,930 a month (the result measured later in this chapter). Callum compares two designs.
- 50/50 for eight weeks. Smallest detectable effect 15.5%. Half the visitors go without search for eight weeks, which is months. Cost: .
- 80/20 for sixteen weeks. With 152,000 visitors the smallest detectable effect is 14.1%. A fifth of the visitors go without search for months. Cost: .
The longer, smaller holdout is slightly more precise and about €1,090 less expensive. It is slower to answer, which matters if the decision is urgent. For search it is not, so Callum chooses 80/20 for sixteen weeks.
Triggering: count only the visitors who could have been affected
Some parts are seen by only a few visitors: a delivery slot picker on furniture pages, a size guide on rugs. If you analyse everyone, the visitors who never saw the part add noise and no signal. Triggering means analysing only the visitors who reached the point where the part would have appeared, in both groups. In the holdout you log the moment the part would have been shown, without showing it. Kohavi, Tang and Xu describe triggering as a way to gain statistical power by filtering out users who could not have been affected6.
The rule that keeps it honest: the trigger must be the same in both groups and must happen before the part could change behaviour. "Visited a furniture product page" works. "Opened the slot picker" does not, because only one group has a picker to open.
Example: the furniture delivery slot picker
Shannonside wants to know whether letting customers pick a two person delivery slot on sofa and sideboard pages pays for itself. In eight weeks 12,000 of the 80,000 test visitors view a furniture page. They place 470 orders with an average contribution of €38 and a standard deviation of €34. Suppose the picker lifts their contribution by 12%.
Analysed across all 80,000 visitors, a 12% lift among 12,000 people becomes a lift of only 4.1% overall, against a smallest detectable effect of 15.5%. The test would see a quarter of what it needs.
Triggered on the 12,000, the baseline is per visitor, , and
so and with 6,000 visitors in each group the smallest detectable effect is , which is 34% of €1.49. The test now sees about a third of what it needs, instead of a quarter. Triggering helped, and it still is not enough. Callum records the picker as "not measurable at our size" and Niamh decides on cost and on what the customer service team hears. Knowing that before running a test is worth as much as a test result.
Some parts cannot be split by visitor: switchbacks
Some parts should not differ between two visitors at the same moment. A delivery charge is the clearest case. Two customers comparing notes would find different charges for the same basket, and customer service would have to explain it. There is also the law. Schedule 3 to the Consumer Rights Act 2022 requires a trader to tell consumers, where applicable, that a price was personalised on the basis of automated decision making7. Whether a random test counts is a question for a lawyer, and a design that shows everyone the same charge avoids it.
That design is a switchback: everyone gets version A for a period, then everyone gets version B, alternating, with the order of each pair chosen at random. Each period is one data point. Switchbacks are widely used where splitting users is impossible, and the research on them focuses on the main risk, the carryover effect: what happened in one period still influencing the next8. A customer who saw free delivery on Sunday and orders on Monday is the carryover in a shop.
The analysis compares the two versions within each pair, which cancels slow trends such as the season:
where is the average difference in contribution between version B and version A across the pairs, is the number of pairs, is the standard deviation of those differences, and is the value from the t distribution with degrees of freedom that gives a 95% interval. See Foundations: confidence intervals.
Example: free delivery for everything, or a charge under €40
Shannonside delivers every order free. The unit economics chapter works out on paper what a delivery charge on small baskets is worth, and ends with the advice to test it. Niamh wants to test €5.90 on baskets under €40. Callum runs six pairs of weeks. In each pair a coin decides which week comes first. The rule changes at midnight on Sunday, shown on every page and in the basket, and orders count to the week in which the basket was started, which limits carryover.
| Pair | Week with free delivery (€) | Week with €5.90 under €40 (€) | Difference (€) |
|---|---|---|---|
| 1 | 10,083 | 10,558 | 475 |
| 2 | 10,293 | 10,498 | 205 |
| 3 | 9,923 | 10,498 | 575 |
| 4 | 10,353 | 10,253 | minus 100 |
| 5 | 10,193 | 10,598 | 405 |
| 6 | 10,323 | 10,628 | 305 |
The average difference is . The differences from that average are 164.2, minus 105.8, 264.2, minus 410.8, 94.2 and minus 5.8. Their squares add up to 285,621, so . With and :
The charge earns between €60 and €562 more contribution a week, most likely about €311. Per month that is , with an interval of €261 to €2,439. Niamh keeps the charge and puts the measured value in the register.
Part by part: what "off" means and what to watch
Each part of a shop needs its own definition of "off", its own trigger and its own guardrail. The definition matters more than it looks: "off" must be a realistic alternative, the way the shop would work without the part, not a broken page.
| Part | What "off" means | Trigger, if any | Guardrail to watch | Measurable alone at Shannonside's size? |
|---|---|---|---|---|
| Site search | No search box, menus and filters stay | None, everyone could search | Customer service contacts | Probably, if it is worth 15% or more |
| Recommendations | The rows are not rendered | Viewed a product page or the basket | Page load time | Only if large |
| Reviews | No stars and no review text, for every product | Viewed a product page | Return rate | Possibly |
| Delivery date promise | Standard "3 to 5 working days" text instead of a date | Viewed a product page | Late delivery complaints | Only if large |
| Free delivery threshold | Run as a switchback, not a split | Started a basket | Average order value | Yes, by switchback |
| Live chat | No chat button | None | Emails to customer service | No, bundle it |
| Wishlist | No heart icon, saved lists still kept | None | Newsletter sign ups | No, bundle it |
| Quick view | Product tiles link to the product page only | Viewed a category page | Page load time | No, bundle it |
Two parts need a few more words.
Reviews: hide all of them, never only the bad ones
A reviews holdout must hide every review for every product in the holdout group. Hiding only some reviews, for example the negative ones, would not be a test of reviews, and it would also misrepresent what customers think. In Ireland, section 55(1)(zb) of the Consumer Protection Act 2007, inserted by section 157 of the Consumer Rights Act 2022, prohibits submitting false consumer reviews and misrepresenting consumer reviews in order to promote products9. The revised Act on the Law Reform Commission's site shows the provision in its full context10. Hiding only the bad reviews is exactly the kind of misrepresentation to stay well clear of. Showing no reviews at all to a random group misleads nobody about what other buyers said. This is general information and not legal advice.
Example: Shannonside's reviews holdout
Callum runs reviews at 50/50 for eight weeks, triggered on visitors who viewed a product page. Contribution per visitor is 12.0% higher with reviews, with a 95% interval of 1.1% to 22.9%. The return rate is 8.6% with reviews and 9.4% without, which fits the idea that reviews help people choose the right item. Both numbers go into the register.
Small parts: test them as a bundle
Chat, wishlist and quick view are each far too small to measure alone. Switched off together, as one "extras" bundle, they have a chance. If the bundle shows no value, at least one part in it is worth little, and the costs decide which goes first. If it shows value, you test the halves of the bundle next.
Example: the extras bundle
The bundle runs 50/50 for eight weeks. Contribution per visitor is 0.8% higher with the extras, with an interval of minus 10.1% to plus 11.7%. That is "cannot tell". The bundle costs €640 a month: €320 for the chat software, about €250 of staff time answering chats, and about €70 of upkeep for the other two. Live chat is almost all of the cost. The decision is made later in the chapter, with the register.
Parts are not additive: interactions
Measure each part alone and add up the results, and you will usually get the wrong total. Parts overlap. Search and recommendations both help people find products. Switch off one, and the other catches some of the visitors who would have used it. Each measured alone looks smaller than it is, and both together are worth more than the sum.
If two tests run at the same time with independent assignments (different names in the hash), every combination of the two exists in the data, and you can see the overlap. With a 50/50 split each, a quarter of visitors are in each combination.
Example: search and recommendations together
Callum looks at contribution per visitor in the four combinations during a period when both tests ran. The numbers are illustrative. With only a quarter of the visitors in each cell they are noisy.
| Recommendations on | Recommendations off | |
|---|---|---|
| Search on | €0.678 | €0.661 |
| Search off | €0.588 | €0.531 |
With recommendations on, search is worth per visitor. With recommendations off, search is worth . Recommendations alone, with search on, are worth . Adding the two single effects gives , but switching both off costs . The parts are partial substitutes. The lesson for the register: record each value as "with everything else on", and never add the column up and call it the value of the whole shop.
Why owning the code makes this possible
A holdout needs three things: a switch that turns a part off for chosen visitors, a record of which visitor was in which group, and a way to join that record to orders, costs and returns. In a shop where every part is your own code, all three are ordinary engineering. Every part sits behind a flag, every exposure is a row in your own database, and every order already carries its contribution. That is the practical meaning of owning your business data.
Rented platforms are moving in this direction, and it is fair to say how far. Shopify's Rollouts can run an Experiment that compares a treatment with a control on the online store, with a default traffic split of 50/50. A rollout can change the main theme, the checkout and accounts configuration, product catalogues and discounts, and experiments are available on the Grow plan or higher11. For comparing two theme designs that is a useful built in tool. Its documented limits are the ones that matter for this chapter: Liquid templates cannot be changed as part of a rollout, headless and custom storefronts are not supported, and experiment reports show conversion, bounce, reached checkout and add to cart rates, with orders and sales available through ShopifyQL queries. Product cost, fulfilment and return costs are not part of them12 (all checked 22 November 2026). Logic that runs on the server, such as how search ranks results, how a delivery date is computed or which products are recommended, lives in the platform or inside an app, and whether an app can be switched off for a random fifth of visitors depends on the app's vendor.
Example: what Callum can test that a theme experiment cannot
Niamh wants to test a change to search ranking: products in stock and with a high margin move up when relevance is equal. This is not a theme change. It is a line in the search service. On Shannonside's own system it is a flag around that line, and the analysis uses contribution per visitor with real product costs and, a month later, real returns. Niamh can also ask the question that matters most for a homeware shop, whether customers who bought through the new ranking come back, by following both groups as cohorts for six months.
Building it: feature flags with Flipper
A feature flag is a switch in the code that decides, for each visitor, whether a part runs. Callum uses Flipper, a widely used Ruby library for flags. Its README shows the setup for Rails with the Active Record adapter, which stores the flags in the shop's own database13. The three commands are:
bundle add flipper-active_record
bin/rails g flipper:setup
bin/rails db:migrate
Flipper can enable a feature for a percentage of actors, where an actor is anything with a flipper_id13. The source shows how the percentage is applied: the feature name and the actor's id are joined, hashed with CRC32 and compared with the percentage, as in the earlier example4. Two consequences follow. A visitor keeps the same group as long as the identifier stays the same. And if you change the percentage halfway through, some visitors switch groups, so the percentage is set once and left alone until the test ends.
Starting the two holdouts takes two lines in the Rails console:
# Search stays on for 80% of visitors in tests; 20% form the holdout
Flipper.enable_percentage_of_actors(:site_search, 80)
# Reviews: a 50/50 test
Flipper.enable_percentage_of_actors(:reviews, 50)
What is the visitor's identifier? Solidus already gives every visitor one. A before_action sets a signed, permanent cookie called guest_token with a random value if the visitor does not have one, and new orders are created with that same guest_token14. So the token links a visitor to their orders without any new tracking. Callum uses it only for visitors who agreed to analytics, because using it for tests is a different purpose from keeping a basket.
Logging who was in which group
The analysis needs to know which visitors were assigned, to which group, and when they first saw the shop under that assignment. One small table holds it:
# db/migrate/20270201090000_create_feature_exposures.rb
class CreateFeatureExposures < ActiveRecord::Migration[8.0]
def change
create_table :feature_exposures do |t|
t.string :visitor_token, null: false
t.string :feature, null: false
t.string :variant, null: false # "on" or "off"
t.datetime :first_seen_at, null: false
end
add_index :feature_exposures, [:visitor_token, :feature], unique: true
end
end
The model writes a row the first time a visitor meets a test and ignores every later visit, thanks to the unique index:
# app/models/feature_exposure.rb
class FeatureExposure < ApplicationRecord
def self.record(token:, feature:, on:)
insert_all(
[{ visitor_token: token, feature: feature.to_s,
variant: on ? "on" : "off", first_seen_at: Time.current }],
unique_by: [:visitor_token, :feature]
)
end
end
A controller concern puts it together. Every view and controller asks feature_on? instead of calling Flipper directly, so the consent check and the logging can never be forgotten:
# app/controllers/concerns/feature_holdouts.rb
module FeatureHoldouts
extend ActiveSupport::Concern
# Parts of the shop that are running as holdout tests right now
HOLDOUTS = %i[site_search reviews].freeze
included do
helper_method :feature_on?
end
# true means the visitor gets the part as normal
def feature_on?(feature)
return true unless HOLDOUTS.include?(feature)
return true unless analytics_consent? # no consent: normal shop, not in the test
@feature_results ||= {}
return @feature_results[feature] if @feature_results.key?(feature)
token = cookies.signed[:guest_token]
on = Flipper.enabled?(feature, Flipper::Actor.new("Visitor;#{token}"))
FeatureExposure.record(token: token, feature: feature, on: on)
@feature_results[feature] = on
end
end
analytics_consent? is the shop's own method that reads the visitor's choice from the consent banner. In the views the check is one line:
<% if feature_on?(:site_search) %>
<%= render "shared/search_box" %>
<% end %>
The search results controller asks the same question, so a visitor in the holdout who types a search address by hand gets the category page instead. Callum writes the tests first: a visitor without consent always sees search, a visitor in the holdout never does, and a second request never adds a second exposure row.
Example: what the exposure table holds after a week
After the first week of the search holdout, the table has 17,000 rows for site_search: 13,615 with on and 3,385 with off. That is 80.1% and 19.9%, inside the guardrail of 79.5% to 80.5%. The split is working, and the test continues.
Consent: who can be in a test
The assignment needs an identifier stored in the visitor's browser, and storing or reading information on a visitor's device is regulated. In Ireland, regulation 5 of S.I. No. 336 of 2011 allows storing information on a user's device, or reading it, only with consent given after clear and comprehensive information, unless the storage is strictly necessary to provide a service the user explicitly asked for15. A holdout run to improve the shop is not strictly necessary for buying a lamp, and the Data Protection Commission enforces these rules, so Shannonside's tests include only visitors who agreed to analytics. This is general information and not legal advice.
Limiting a test to consenting visitors costs visitors, and people who consent may behave differently, so the measured uplift strictly applies to them. For the register, Callum assumes the same relative uplift for every visitor and writes that assumption next to the number.
Example: the size of Shannonside's test population
Shannonside has about 74,000 visitors a month. With 64% consenting, about 47,000 a month can be in tests. Over eight weeks, with returning visitors counted once, that becomes the 80,000 used in all the calculations above. Without the consent limit the same eight weeks would give about 125,000 visitors, and the smallest detectable effect of a 50/50 test would fall from 15.5% to about 12.4%.
The analysis in SQL
Each completed order needs its contribution. The chapter on ROAS, POAS and MER builds an OrderContribution class for Shannonside. Callum stores its result when an order completes, using the Solidus event bus, following the subscriber pattern in the Solidus guides16. The subscriber looks like this:
# app/subscribers/shannonside/contribution_subscriber.rb
module Shannonside
class ContributionSubscriber
include Omnes::Subscriber
handle :order_finalized,
with: :store_contribution,
id: :shannonside_store_contribution
def store_contribution(event)
order = event[:order]
OrderContributionRecord.upsert(
{ order_id: order.id, contribution: OrderContribution.new(order).value },
unique_by: :order_id
)
end
end
end
The query then joins exposures to orders through the guest token, counts only orders completed after the visitor's first exposure and before the test ended, and gives every visitor a total, zero for those who bought nothing:
-- Contribution per visitor in each group of the search holdout
WITH exposed AS (
SELECT visitor_token, variant, first_seen_at
FROM feature_exposures
WHERE feature = 'site_search'
),
per_visitor AS (
SELECT e.variant,
e.visitor_token,
COALESCE(SUM(c.contribution), 0) AS contribution
FROM exposed e
LEFT JOIN spree_orders o
ON o.guest_token = e.visitor_token
AND o.state = 'complete'
AND o.completed_at >= e.first_seen_at
AND o.completed_at < TIMESTAMP '2027-05-24 00:00'
LEFT JOIN order_contribution_records c ON c.order_id = o.id
GROUP BY e.variant, e.visitor_token
)
SELECT variant,
COUNT(*) AS visitors,
ROUND(AVG(contribution), 4) AS contribution_per_visitor,
ROUND(STDDEV_SAMP(contribution), 4) AS sd
FROM per_visitor
GROUP BY variant;
The LEFT JOIN is the important part: without it, visitors who bought nothing would vanish, and contribution per visitor would quietly become contribution per buyer. The contribution stored at completion uses the expected return cost. Thirty days after the test ends, when the return window has closed, Callum runs the query again with the actual refunds subtracted, so a part that raises returns is caught. The returns chapter shows how to work out what a return really costs.
Reading the result: an uplift with an interval
A single number is not a result. A result is a number with an interval that says how far it could be from the truth. For the difference between two group averages:
where is the measured difference in contribution per visitor, is the standard deviation of contribution per visitor, and are the group sizes, and 1.96 gives a 95% interval. See Foundations: confidence intervals. Kohavi, Tang and Xu cover the statistics behind it, including when the simple formula needs adjusting17.
To turn a relative uplift into money per month, ask how much less the whole shop would earn without the part. If the shop earns a month with the part, it would earn without it, so
where is the value of the part per month, is the shop's monthly contribution before marketing with the part, and is the measured uplift. See Foundations: percentages.
Example: the search holdout result
After sixteen weeks, 152,000 visitors are in the test: 121,600 with search and 30,400 without. The query returns €0.654 per visitor with search and €0.566 without. So , and
The interval runs from €0.023 to €0.151 per visitor. As uplifts on the €0.566 without search: , with an interval of 4.0% to 26.8%. In money:
Here euro a month, , and euro a month.
Search is worth about €5,930 a month, and somewhere between €1,709 and €9,393. The report said €16,291. Search really earns about a third of what passes through it, which sits close to what Sharma and colleagues found for recommendations. The guardrails held: the split stayed at 80.0%, returns were the same in both groups, and the holdout wrote 31% more emails to customer service, which is what you would expect when people cannot find things.
The feature value register
The feature value register is one table with a row for every part of the shop: what it is measured to be worth, how sure that is, what it costs, and what was decided. It turns tests into a memory. Without it, the result of a test from last spring lives in someone's inbox and the same argument starts again next year.
Each row holds the uplift and its interval, the monthly value from the formula above, the monthly running cost (software, server, staff time, upkeep), the net value, the guardrail notes, the decision, and the date to test again. Costs include staff time, because a chat window answered by a person is not free.
Example: Shannonside's register after the first year
| Part | Uplift (95% interval) | Value a month | Cost a month | Net a month | Decision | Test again |
|---|---|---|---|---|---|---|
| Site search | 15.4% (4.0% to 26.8%) | €5,930 | €170 | €5,760 | Keep, invest in ranking | Spring 2028 |
| Reviews | 12.0% (1.1% to 22.9%) | €4,761 | €215 | €4,546 | Keep, ask for more reviews | Spring 2028 |
| Delivery date promise | 5.5% (minus 5.4% to 16.4%) | €2,317 | €90 | €2,227 | Keep, retest with a longer holdout | Autumn 2027 |
| Recommendations | 4.0% (minus 6.9% to 14.9%) | €1,709 | €135 | €1,574 | Keep, retest triggered on the basket | Autumn 2027 |
| Delivery charge under €40 | Switchback: €1,350 (€261 to €2,439) | €1,350 | €0 | €1,350 | Adopted | 2028 |
| Extras: chat, wishlist, quick view | 0.8% (minus 10.1% to 11.7%) | €353 | €640 | minus €287 | Drop chat and quick view, keep wishlist | After the change |
| Furniture slot picker | Not measurable at this size | €50 | Keep while customer service supports it | When traffic doubles |
Deciding with an interval, not a verdict
Most rows in a small shop's register will have intervals that include zero. That does not mean "no effect". It means "not proven". Treating every such result as worthless throws away information, and treating every estimate as fact ignores the uncertainty. The useful question is: given what was measured, how likely is the part to be worth more than it costs? With the estimate and its standard error, a normal approximation answers it:
where is the uplift at which the part exactly pays for itself, is the measured uplift, is its standard error (the half width of the 95% interval divided by 1.96), and is the cumulative normal distribution. See Foundations: distributions and Foundations: probability. The idea of weighing outcomes by their probability is in Foundations: expected value.
Example: recommendations and the extras bundle
Recommendations cost €135 a month. They pay for themselves if , so . The measured uplift is with a half width of 10.9 points, so points, and
Here , and points.
A one in four chance that recommendations do not pay for themselves, three in four that they do, and the expected value of €1,709 against €135 of cost. Keep them, and test again with a longer holdout triggered on basket views.
The extras bundle costs €640, so . With and the same standard error,
Here , and points.
More likely than not, the bundle costs more than it earns. Live chat is €570 of the €640, and the guardrail showed no rise in emails when chat was off. Niamh drops chat and quick view, keeps the wishlist because it costs almost nothing and feeds the back in stock emails, and writes the reasoning into the register so it can be revisited.
That is the whole method in one sentence: measure each part against a random group without it, size the test before you start, decide with the interval, and keep the register. The chapter on the improvement loop turns the register into a monthly routine, and the chapter on experiments goes deeper into the engineering, from sample ratio checks to variance reduction and long running holdouts.
Conclusion
Reports tell you what passed through a part of your shop. Only a comparison with a random group that went without it tells you what the part earned. At Shannonside that was about a third of what the search report claimed.
Measure on contribution per visitor, set guardrails before you start, and calculate the smallest effect the test can see before you hold anything back. For a shop with around 2,000 orders a month that number is sobering: big parts can be measured, small ones only in bundles or on cost. Use triggering where a part is seen by few visitors, switchbacks where everyone must see the same thing, and never add up separately measured values as if the parts did not overlap.
All of this is ordinary engineering when the shop is your own code: a flag around each part, a table of exposures, and a query that joins them to orders and costs you already hold. Keep the results in a register, decide with the interval, and test again when traffic grows.