Group web forms by how many fields they show and compare conversion rates.
Input is a CSV with the columns form, fields (a positive whole number),
views and submissions (non-negative whole numbers, submissions <= views).
Extra columns are ignored. Every form name may appear only once.
Buckets by field count:
- short: fewer than
mid_fromfields (default: 1 to 3) - mid:
mid_fromor more but fewer thanlong_from(default: 4 to 6) - long:
long_fromor more (default: 7 or more)
mid_from and long_from are parameters set by you, not rules. They must satisfy
2 <= mid_from < long_from.
Conversion rate is submissions / views as a percent, rounded half up to 2 decimals,
and n/a when there are no views. Best and worst form of a bucket are picked by exact
conversion rate (ties by form name, alphabetical); forms with 0 views are ignored for
best and worst.
Summary
Functions
Bucket name for a field count.
Check the bucket limits: 2 <= mid_from < long_from.
Parse the CSV text into a list of form rows.
Divide num / den * mult exactly (integers only) and format with decimals places,
rounding half up. Returns "n/a" when den is zero.
Printable report: bucket table with a total row, then best and worst form per bucket.
Per-bucket summary. Returns three maps (short, mid, long) with the keys bucket,
forms, views, submissions, best and worst (a form row or nil).
Types
@type form_row() :: %{ form: String.t(), fields: pos_integer(), views: non_neg_integer(), submissions: non_neg_integer() }
Functions
@spec bucket(pos_integer(), pos_integer(), pos_integer()) :: :short | :mid | :long
Bucket name for a field count.
Check the bucket limits: 2 <= mid_from < long_from.
Parse the CSV text into a list of form rows.
@spec ratio(integer(), integer(), integer(), non_neg_integer()) :: String.t()
Divide num / den * mult exactly (integers only) and format with decimals places,
rounding half up. Returns "n/a" when den is zero.
@spec render([form_row()], pos_integer(), pos_integer()) :: String.t()
Printable report: bucket table with a total row, then best and worst form per bucket.
@spec summarize([form_row()], pos_integer(), pos_integer()) :: [map()]
Per-bucket summary. Returns three maps (short, mid, long) with the keys bucket,
forms, views, submissions, best and worst (a form row or nil).