CLI Metrics Commands
Two command groups, matching the two halves of the metric model:
avsb metricsmanages tracking definitions: what counts as a click, a pageview, or a custom event.avsb metric-bindingsmanages how a tracked thing is measured: conversions per visitor, total value, a rate, a percentile, and so on.
See What Are Metrics? for the concepts. This page is the command reference.
Choosing the project
Every command in both groups accepts --project, taking either form of the project ID:
avsb metrics list --project PRJ-42avsb metrics list --project 42Inside a folder created by avsb project pull, the project comes from the local .avsb-project.json manifest and --project can be omitted. A folder created by avsb clone works the same way, from its .avsb.json manifest. Outside both, without the flag, the command stops and says so.
avsb metrics
avsb metrics list
avsb metrics list --project PRJ-42avsb metrics list --type clickavsb metrics list --include-archivedavsb metrics list --json| Flag | Meaning |
|---|---|
--type <type> | Filter by CLICK, PAGEVIEW, or CUSTOM (case-insensitive) |
--include-archived | Include archived metrics, marked (archived) |
--json | Print the platform's own rows as one JSON document instead of a table |
--quiet | Print the result only |
The table shows each metric's MET- ID, type, name, definition (selector, URL pattern, or event key), and usage as <experiments>m/<flag rules>r, so you can see what a change would affect before you make it.
With --json, data is the platform's answer: the metrics, and their usage keyed by metric ID.
{ "ok": true, "command": "metrics list", "data": { "metrics": [{ "id": "cm...", "shortId": 17, "name": "Add to cart", "type": "CLICK", "cssSelector": ".btn-add-to-cart" }], "usage": { "cm...": { "experimentCount": 2, "flagRuleCount": 0 } } }}avsb metrics create
--type and --name are always required. The rest depends on the type:
# a click on a selectoravsb metrics create --type click --name "Add to cart" --selector ".btn-add-to-cart"# a pageview on a URL patternavsb metrics create --type pageview --name "Checkout complete" \ --url-match "/order/confirmation" --match-mode PATH# a custom event that carries a numeric valueavsb metrics create --type custom --name "Purchase" --key purchase --has-value| Flag | Applies to | Meaning |
|---|---|---|
--type <type> | all | CLICK, PAGEVIEW, or CUSTOM |
--name <name> | all | Display name |
--description <text> | all | Optional description |
--selector <css> | CLICK | CSS selector to match clicks against. Required |
--page-url <url> | CLICK | Only count clicks on pages matching this URL |
--url-match <pattern> | PAGEVIEW | URL pattern to match. Required |
--match-mode <mode> | PAGEVIEW | SIMPLE, EXACT, PATH, SUBSTRING, PATTERN, or REGEX. Defaults to SIMPLE |
--key <eventKey> | CUSTOM | Event key your code sends. Required |
--has-value | CUSTOM | The event carries a numeric value (revenue, quantity, and so on) |
A missing type-specific flag stops the command with a message naming it, for example CLICK metrics require --selector "<css>". A name or key that is already taken stops with exit code 4 and the reason.
avsb metrics update <metricId>
Takes the metric's ID in any form the CLI shows: MET-17, 17, or the long ID. Add at least one field to change. It accepts the same field flags as create, and adds --no-has-value to turn value tracking off.
avsb metrics update 17 --name "Add to bag"avsb metrics update 17 --selector ".btn-add-to-bag" --page-url "/product/*"avsb metrics update 21 --no-has-valueWith no field flags, the command stops rather than sending an empty change.
avsb metrics archive and unarchive
avsb metrics archive 17avsb metrics unarchive 17Archiving hides a metric from pickers while keeping its history and any experiment that used it. This is the safe way to retire a metric. An ID that matches no metric in the project answers Metric not found.
avsb metrics delete <metricId>
avsb metrics delete 17 # asks for confirmationavsb metrics delete 17 -f # skips the prompt, for scriptsDeletion is refused while any metric binding references the metric. When that happens the CLI names what is in the way, exits with code 4, and suggests avsb metrics archive instead. In a run that cannot ask for confirmation (CI, a pipe), pass -f; without it the command stops and says so.
avsb metric-bindings
avsb metric-bindings list
avsb metric-bindings list --project PRJ-42avsb metric-bindings list --library --search revenue| Flag | Meaning |
|---|---|
--library | Only saved library bindings |
--search <text> | Case-insensitive name filter |
--include-archived | Include archived bindings |
--limit <n> | Maximum rows, 1 to 500. Defaults to 200 |
--json | Print the platform's own rows as one JSON document instead of a table |
--quiet | Print the result only |
Each row shows the MBD- ID, the measure, the name, and a plain-English sentence of what it measures, for example "Increase in unique conversions per visitor for Add to cart (.btn-add-to-cart)."
With --json, data is { "metricBindings": [...] }, the platform's own rows.
avsb metric-bindings create
--measure and --name are required, plus whichever metric flags the measure needs.
# conversions per visitor on one metricavsb metric-bindings create --measure unique_conversions_per_visitor \ --metric 17 --name "Add to cart rate"# a rate: numerator over denominatoravsb metric-bindings create --measure rate \ --numerator-metric 21 --denominator-metric 17 --name "Purchase per cart add"# a percentile of a numeric field, trimmed at the top 1 percentavsb metric-bindings create --measure percentile --percentile 90 \ --metric 21 --value-source value --winsorize-upper 99 \ --name "p90 order value"# a weighted composite of two metric bindingsavsb metric-bindings create --measure composite --name "Engagement" \ --component MBD-8:0.5 --component MBD-9:0.5| Flag | Meaning |
|---|---|
--measure <measure> | One of the measures below. Hyphens are accepted in place of underscores |
--direction <dir> | INCREASE (default) or DECREASE: which way is good |
--name <name> | Display name |
--description <text> | Optional description |
--metric <metricId> | Source metric, for the single-metric measures. MET-17, 17, or the long ID |
--numerator-metric <metricId> | Numerator, required for RATE. Any metric ID form |
--denominator-metric <metricId> | Denominator, required for RATE. Any metric ID form |
--component <bindingId:weight> | One COMPOSITE component: a metric binding (MBD-8, 8, or the long ID) and its weight. Repeat the flag for each. COMPOSITE needs at least 2 |
--composition <json> | COMPOSITE components as JSON, for example '[{"metricId":"MBD-8","weight":1}]'. The metricId key names a metric binding. At least 2 entries |
--percentile <n> | Required for PERCENTILE, strictly between 0 and 100 |
--value-source <name> | Numeric field to read for value and percentile measures. Defaults to value |
--winsorize-upper <pct> | Upper trim percentile. Setting either bound turns winsorization on |
--winsorize-lower <pct> | Lower trim percentile |
Measures:
| Measure | What it computes |
|---|---|
UNIQUE_CONVERSIONS_PER_VISITOR | Visitors who converted at least once, per visitor |
TOTAL_EVENTS | Every firing, including repeats |
UNIQUE_VISITORS_WHO_FIRED | Distinct visitors who fired the event |
TOTAL_VALUE_PER_VISITOR | Sum of the numeric field, per visitor |
TOTAL_VALUE | Sum of the numeric field |
PERCENTILE | A percentile of the numeric field |
RATE | One metric divided by another |
COMPOSITE | A weighted combination of several metrics |
avsb metric-bindings update <id>
Takes the binding's ID in any form the CLI shows: MBD-8, 8, or the long ID. Same flags as create (except --measure, which is fixed once created), plus --library and --no-library to move a binding in and out of the library.
avsb metric-bindings update 8 --direction DECREASEavsb metric-bindings update 8 --libraryIf the change affects a sealed analysis plan, the CLI says an amendment is required and names the fields involved.
avsb metric-bindings archive, unarchive, and delete
avsb metric-bindings archive 8avsb metric-bindings unarchive 8avsb metric-bindings delete 8 -fDeletion is refused while an experiment still attaches the binding; the CLI then names the experiments, exits with code 4, and suggests archiving instead. An ID that matches no binding in the project answers Metric binding not found.
Scripting these commands
Both groups authenticate like every other command, so AVSB_TOKEN is all a job needs:
export AVSB_TOKEN=avsb_pat_...avsb metrics list --project 42See CLI Authentication. avsb metrics list and avsb metric-bindings list take --json, so a script can parse the platform's own rows directly. create, update, archive, unarchive, and delete print for a human only and have no --json flag, so prefer the REST API when a script needs to parse the result of one of those.