GrepBoard/Manuals
605 manuals ·

Get funnel step conversion and drop-off rates with a stated base

·Tested on Gemini 3.8 Flash · Python 3.13 · 2026-10·Test scope ↓

Raw funnel counts give Gemini tables in a new shape each run. Put both bases in columns, recompute every rate by script, and check drop-off = 100 − conversion.

Visit 18,420, product page 6,934, cart 1,507, purchase 412. Ask an AI which step leaks the most and it will answer well. What changes from answer to answer is the base of "conversion": the previous step or the first step.

The short prompt

The numbers are a fictional shop's two weeks.

text
Weekly funnel for an online shop (users per step)Week 1: Visit 18420, Product page 6934, Cart 1507, Purchase 412Week 2: Visit 21050, Product page 7516, Cart 1921, Purchase 438

One sentence went in front: "Using the funnel numbers below, work out the conversion and drop-off rate for each step and tell me which step leaks the most." Three runs in English, three in Korean. The first English output had separate tables per week with step-to-step conversion and drop-off rates, plus an overall Visit → Purchase figure.

The numbers are right. No place in these 6 runs mixed up the bases, and the percentages that were not in the tables (two-week totals, share of total loss) also match the raw counts when recomputed. The trouble is that the six answers have six shapes.

  • A per-step "share of first step" column: 1 of 6 runs (the first Korean run). The others give one overall Visit → Purchase figure.
  • "Most leaky step" answered two ways, by rate and by number of users lost: all 6. Week 1 is "Product page → Cart" by rate and "Visit → Product page" by users.
  • An extra two-week combined row or table: 3 of 6 (all English runs), labeled "average" but computed on summed counts. Avg. Conversion 36.61% in the first English output is 14,450 ÷ 39,470, while the average of the two weekly rates 37.64 and 35.71 is 36.675.

A prompt with both bases as columns

Google's prompting strategies say you can specify the response format, such as a table, and warn that too many examples can make the model overfit to them. So the prompt has three definitions, one table format, and a single example that only shows the shape.

text
Using the weekly funnel numbers in <data>, calculate the step rates. Definitions (use only these):- prev_rate = users at the step ÷ users at the previous step × 100- first_rate = users at the step ÷ users at the first step (Visit) of that week × 100- drop_prev = 100 − prev_rate- For the first step (Visit) write - for prev_rate and drop_prev, and 100.0 for first_rate. Output format (write nothing outside it):1. One Markdown table with the columns week | step | users | prev_rate | first_rate | drop_prev. Include all 4 step rows for each week. Rates are numbers only, no % sign, rounded to one decimal place.2. Below the table, one line per week: LEAK {week}: {from step}→{to step}, the step pair with the largest drop_prev. Example (numbers only show the format and are unrelated to the data below):Input: Week 1 A 1000, B 400, C 100Output:| week | step | users | prev_rate | first_rate | drop_prev ||---|---|---|---|---|---|| Week 1 | A | 1000 | - | 100.0 | - || Week 1 | B | 400 | 40.0 | 40.0 | 60.0 || Week 1 | C | 100 | 25.0 | 10.0 | 75.0 |LEAK Week 1: B→C <data>{users per step, one line per week}</data>

"Most leaky step" is pinned to the rate.

console
$ agy -p "$(cat rules.en.txt)" --model gemini-3.8-flash --effort high --output-format text > out.rules.en.1.txt$ cat out.rules.en.1.txt| week | step | users | prev_rate | first_rate | drop_prev ||---|---|---|---|---|---|| Week 1 | Visit | 18420 | - | 100.0 | - || Week 1 | Product page | 6934 | 37.6 | 37.6 | 62.4 || Week 1 | Cart | 1507 | 21.7 | 8.2 | 78.3 |…| Week 2 | Purchase | 438 | 22.8 | 2.1 | 77.2 |LEAK Week 1: Product page→CartLEAK Week 2: Cart→Purchase

The three Korean outputs were identical to the character. The three English ones were identical except that the second has one extra blank line (checked with diff).

Recompute and compare

In a spreadsheet, put =C3/B3*100, =C3/$B3*100 and =100-conversion in columns; the script below does the same. A rate must equal the value rounded to one decimal place exactly, and drop_prev must be within 0.1 of 100 − prev_rate.

check_funnel.py
#!/usr/bin/env python3"""usage: check_funnel.py data.txt out.txtRecomputes prev_rate / first_rate / drop_prev from the raw counts and compares them with the AI table."""import math, re, syssys.stdout.reconfigure(encoding="utf-8") # 1. raw counts: "<week label>: step n, step n, ..."data = {}for line in open(sys.argv[1], encoding="utf-8"):    m = re.match(r"^(.+?):\s*(.+)$", line.strip())    if not m or not re.search(r"\d", m.group(2)):        continue    steps = re.findall(r"([^\d,]+?)\s+(\d[\d,]*)", m.group(2))    data[m.group(1).strip()] = [(s.strip(), int(n.replace(",", ""))) for s, n in steps]if not data:    print("FAIL no data rows parsed"); sys.exit(2) # 2. expected valuesexp = {}leak = {}for wk, steps in data.items():    first = steps[0][1]    worst = None    for i, (name, n) in enumerate(steps):        prev = None if i == 0 else n / steps[i - 1][1] * 100        exp[(wk, name)] = (n, prev, n / first * 100, None if prev is None else 100 - prev)        if prev is not None and (worst is None or 100 - prev > worst[0]):            worst = (100 - prev, steps[i - 1][0], name)    leak[wk] = (worst[1], worst[2]) # 3. AI tabletext = open(sys.argv[2], encoding="utf-8").read()COLS = ["week", "step", "users", "prev_rate", "first_rate", "drop_prev"]def num(c):    c = c.strip().replace(",", "").rstrip("%").strip()    if c in ("-", ""):        return None    try:        v = float(c)    except ValueError:        return float("nan")    return v if math.isfinite(v) else float("nan")   # nan/inf never compare as equalrows, pos = [], Nonefor l in text.splitlines():    if l.strip().startswith("|"):        cells = [c.strip() for c in l.strip().strip("|").split("|")]        if pos is None:            if all(n in cells for n in COLS):          # header row: find columns by name                pos = [cells.index(n) for n in COLS]        elif len(cells) > max(pos) and not set(cells[0]) <= set("-: "):            rows.append([cells[i] for i in pos])if pos is None:    print("FAIL no header row with columns", COLS); sys.exit(1) bad = 0seen = set()for wk, step, users, prev, first, drop in rows:    key = (wk, step)    if key not in exp:        print(f"FAIL unknown row {key}"); bad += 1; continue    seen.add(key)    n, e_prev, e_first, e_drop = exp[key]    got = (num(users), num(prev), num(first), num(drop))    want = (n, e_prev, e_first, e_drop)    msgs = []    if got[0] != n: msgs.append(f"users {got[0]} != {n}")    for label, g, w in (("prev_rate", got[1], want[1]), ("first_rate", got[2], want[2]), ("drop_prev", got[3], want[3])):        if w is None:            if g is not None and not (label == "first_rate"): msgs.append(f"{label} should be -")        elif g is None or not abs(g - round(w, 1)) <= 1e-6:            msgs.append(f"{label} {g} != {round(w, 1)}")    if got[1] is not None and got[3] is not None and not abs(got[3] - (100 - got[1])) <= 0.1001:        msgs.append(f"drop_prev {got[3]} != 100 - prev_rate {got[1]}")    print(("FAIL " if msgs else "ok   ") + f"{wk} {step}" + ("  <- " + "; ".join(msgs) if msgs else ""))    bad += bool(msgs)missing = set(exp) - seenif missing:    print("FAIL missing rows:", sorted(missing)); bad += 1if len(rows) != len(exp):    print(f"FAIL row count {len(rows)} != {len(exp)}"); bad += 1 # 4. LEAK linesgot_leak = {}for m in re.finditer(r"^LEAK\s+(.+?):\s*(.+?)\s*[→>-]+>?\s*(.+?)\s*$", text, re.M):    got_leak[m.group(1)] = (m.group(2), m.group(3))for wk, want in leak.items():    g = got_leak.get(wk)    flag = "ok   " if g == want else "FAIL "    bad += g != want    print(f"{flag}LEAK {wk}: got {g} want {want}")print(f"{len(rows)} rows, {bad} problems")sys.exit(1 if bad else 0)
console
$ python3 -I check_funnel.py data.en.txt out.rules.en.1.txt | tail -1; echo "exit ${PIPESTATUS[0]}"8 rows, 0 problemsexit 0

All 6 outputs of the fixed prompt (3 English, 3 Korean) exited 0.

Testing the checker

The first English fixed-prompt output was broken by hand in 13 ways, one change each (swapped base, swapped column headers, NaN, 0.1 off, deleted row, empty file and so on). Only 37.6%, which should pass, exited 0; the other 12 exited 1 (these are not model outputs). One example, Week 1 Cart prev_rate replaced by the first-step value 8.2:

console
$ python3 -I check_funnel.py data.en.txt badEn/mixed.txt | grep FAILFAIL Week 1 Cart  <- prev_rate 8.2 != 21.7; drop_prev 78.3 != 100 - prev_rate 8.2

The first version accepted anything within ±0.05 (so 37.64 passed), trusted column positions (swapped prev_rate/first_rate headers passed) and let NaN through. Now columns are found by header name and only a finite number equal to the one-decimal rounded value passes. The other inputs are in run/badEn/.

Where it still goes wrong

  • LEAK is a matter of definition. Because it is pinned to the rate, Week 2 answers "Cart → Purchase". The short-prompt answers also gave "Visit → Product page" by number of users lost. Write the basis your report needs into the prompt.
  • The script checks arithmetic only. The AI's explanations of why users dropped (shipping fees, payment errors) are guesses that the numbers cannot support. 4 of the 6 short answers (the 3 Korean ones and the second English one) also had such a paragraph on shipping costs and payment errors.
  • When not to trust it. Whether "users per step" are unique users or sessions, and whether every user must pass each step in order, changes what a rate means. Check how your analytics tool defines the numbers, and if a later step has more users than the one before it, find out why first.

#funnel#conversion-rate#gemini#prompt