Sub topic 10
Comparing Before and After Against a Control Group
This chapter assumes that you understand Search Console clicks, impressions, CTR, and average position. You should also know basic pandas and understand that correlation does not prove causation.
Why a simple before-and-after comparison is weak
Suppose queries that later show AI Overviews had a 10% CTR before exposure and a 7.5% CTR afterward. The 2.5 percentage-point drop looks important, but it does not identify the cause.
Other changes may have happened during the same period:
- Search demand may have changed because of seasonality.
- Rankings may have fallen.
- A Google core update may have changed results.
- The site may have changed its title tags or snippets.
- Analytics or Search Console tracking may have changed.
A control group helps account for changes that affect both exposed and unexposed queries. The control group should be similar to the exposed group but should not be exposed to the feature being studied.
Difference-in-differences
Difference-in-differences compares the change in the exposed group with the change in the control group.
The calculation is:
- Calculate the exposed group's post-period CTR minus its pre-period CTR.
- Calculate the control group's post-period CTR minus its pre-period CTR.
- Subtract the control change from the exposed change.
| Group | Pre-period CTR | Post-period CTR | Change |
|---|---|---|---|
| Exposed queries | 10.00% | 7.50% | -2.50 percentage points |
| Control queries | 10.00% | 9.55% | -0.45 percentage points |
The estimated effect is:
-2.50 - (-0.45) = -2.05 percentage points
This estimate says that exposed queries declined about 2.05 percentage points more than control queries. It does not prove that AI Overviews caused the entire decline. It is an estimate based on the design and its assumptions.
import pandas as pd
data = pd.DataFrame([
{"group": "exposed", "period": "pre", "clicks": 100, "impressions": 1000},
{"group": "exposed", "period": "post", "clicks": 90, "impressions": 1200},
{"group": "control", "period": "pre", "clicks": 200, "impressions": 2000},
{"group": "control", "period": "post", "clicks": 210, "impressions": 2200},
])
data["ctr"] = data["clicks"] / data["impressions"]
ctr = data.set_index(["group", "period"])["ctr"]
exposed_change = ctr.loc[("exposed", "post")] - ctr.loc[("exposed", "pre")]
control_change = ctr.loc[("control", "post")] - ctr.loc[("control", "pre")]
difference_in_differences = exposed_change - control_change
print(f"Exposed change: {exposed_change:.4%}")
print(f"Control change: {control_change:.4%}")
print(f"Estimated effect: {difference_in_differences:.4%}")Choosing a credible control group
A useful control group should resemble the exposed group before the study begins. Compare the groups on:
- Average position and position distribution
- Impressions and query volume
- Device and country mix
- Search intent
- Landing-page type
- Brand versus non-brand status
Do not choose a control group only because its result produces a convenient answer. Document the selection rule before examining the final result. For example, you might match non-brand informational queries to exposed informational queries by country, device, and pre-period position range.
The key assumption is parallel trends. This means that, without the AI Overview exposure, the exposed and control groups would have changed in similar ways. You cannot observe this directly, but you can inspect several periods before exposure. If the groups already move differently, the estimate is less credible.
Interpreting the result
Check rankings, impressions, clicks, and conversion metrics alongside CTR. A CTR decline with stable position is consistent with a results-page change, but it is not conclusive evidence. A simultaneous ranking decline points to another explanation or a mixed effect.
Report the time windows, cohort rules, sample sizes, metric definition, estimated effect, and known confounders. Tie the estimate to a decision, such as testing a clearer title, prioritizing pages that answer complex queries, or continuing measurement until more data accumulates.
Exercise
The exposed group's CTR falls by 3 percentage points, while the control group's CTR falls by 1 percentage point. What is the difference-in-differences estimate?
Show answer
The estimate is -2 percentage points: -3 minus -1. The exposed group declined 2 percentage points more than the control group.