p202 analytics

Query performance stats grouped by campaign, traffic source, country, etc. (shorthand for report breakdown)

All commands

01Run it

Straight from the command's own help.

p202 analytics --group-by country --period last30
p202 analytics --group-by country --split-at 2026-09-04

02What you get

Captured from the real binary, run against a demo store with 30 days of traffic. Switch tabs to see the same run as JSON, the shape scripts and agents parse.

p202 analytics --group-by country --period last30
$ p202 analytics --group-by country --period last30
id  name            Clicks  Clickthroughs  Conversions  Conv %  Revenue  Cost    Profit   ROI %     EPC     CPA      Avg CPC
--  --------------  ------  -------------  -----------  ------  -------  ------  -------  --------  ------  -------  -------
2   United States   1757    1757           79           4.4963  8321     938.44  7382.56  786.6843  4.7359  11.879   0.5341
3   United Kingdom  451     451            10           2.2173  4487     489.10  3997.90  817.3993  9.949   48.91    1.0845
1   Canada          316     316            18           5.6962  1231     374.30  856.70   228.8806  3.8956  20.7944  1.1845
4   Australia       293     293            14           4.7782  1798     119.54  1678.46  1404.099  6.1365  8.5386   0.408
5   Germany         84      84             0            0       0        111.60  -111.60  -100      0       0        1.3286
Real output · p202 1.9.77 · demo dataexit 0

Profit by country

  • United States$7,382.56
  • United Kingdom$3,997.90
  • Australia$1,678.46
  • Canada$856.70
  • Germany-$111.60

Drawn from the JSON output above. Losses run left of zero in orange.

p202 analytics --group-by campaign --split-at 2026-09-25
$ p202 analytics --group-by campaign --split-at 2026-09-25
id  name                          clicks_before  clicks_after  clicks_change  clicks_change_pct  clicks_per_day_before  clicks_per_day_after  clicks_per_day_change_pct  conversions_before  conversions_after  conversions_change_pct  revenue_before  revenue_after  revenue_change_pct
--  ----------------------------  -------------  ------------  -------------  -----------------  ---------------------  --------------------  -------------------------  ------------------  -----------------  ----------------------  --------------  -------------  ------------------
1   Spring Collection / US        340            447           107            31.47              4.4985                 31.0009               589.14                     13                  11                 -15.38                  1916            1462           -23.70
5   Free Trial to Paid / CA       116            182           66             56.90              1.5348                 12.6223               722.42                     7                   11                 57.14                   203             319            57.14
6   Bakery Pre-orders / Local     95             143           48             50.53              1.2569                 9.9175                689.03                     11                  7                  -36.36                  888             492            -44.59
2   Coffee Subscription / US      251            293           42             16.73              3.3209                 20.3205               511.89                     17                  13                 -23.53                  674             442            -34.42
3   Standing Desk Launch / UK     208            230           22             10.58              2.752                  15.9513               479.62                     3                   5                  66.67                   1702            1849           8.64
7   Holiday Gift Cards / AU       136            152           16             11.76              1.7994                 10.5417               485.85                     5                   8                  60                      475             975            105.26
4   Project Tool Pro Annual / US  151            157           6              3.97               1.9979                 10.8885               445.01                     3                   7                  133.33                  1284            3156           145.79
Split at 2026-09-25T00:00:00Z (1790294400); window: default --days 90
  before 2026-07-11T10:03:14Z .. 2026-09-24T23:59:59Z  75.58 days  clicks 1297 (17.16/day)  conversions 59 (0.78/day)  revenue 7142 (94.49/day)
  after  2026-09-25T00:00:00Z .. 2026-10-09T10:03:14Z  14.42 days  clicks 1604 (111.24/day)  conversions 62 (4.3/day)  revenue 8695 (603.03/day)
7 value(s), 7 shown, ranked by |clicks_change| DESC. The sides differ in length: compare the *_per_day columns, not the totals.
Real output · p202 1.9.77 · demo dataexit 0

03Build your command

Pick values and the command line writes itself, quoted and ready to paste.

p202 analytics

Set flags below; the command updates as you type.

04Flags

27 flags, plus the global flags every command takes.

FlagWhat it does
--aff-campaign-idstringFilter by INTERNAL campaign id (from campaign list), not the public id in tracking URLs
--aff-network-idstringFilter by affiliate network ID
--browser-idstringFilter by browser ID (the id of a --breakdown browser row)
--country-idstringFilter by country ID
--daysintRelative window: the last N×24 hours, ending now (ignored when --period is provided; --period lastN counts whole days from a midnight)
--device-typestringFilter by device type ID: 1 Desktop, 2 Mobile, 3 Tablet, 4 Bot (the ids of --breakdown device_type rows)
--group-bystringBreakdown dimension: campaign, aff_network, ppc_account, ppc_network, landing_page, keyword, country, city, region, browser, platform, device, isp, text_ad, ip, referer, referer_url, device_type, c1, c2, c3, c4, utm_source, utm_medium, utm_campaign, utm_term, utm_content, rotator, rotator_rule (aliases: geo=country, lp=landing_page, network=aff_network, offer=campaign, referrer=referer, referrer_url=referer_url, rule=rotator_rule, source=ppc_account)
campaignaff_networkppc_accountppc_networklanding_pagekeywordcountrycityregionbrowserplatformdeviceisptext_adiprefererreferer_urldevice_typec1c2c3c4utm_sourceutm_mediumutm_campaignutm_termutm_contentrotatorrotator_rulegeo → countrylp → landing_pagenetwork → aff_networkoffer → campaignreferrer → refererreferrer_url → referer_urlrule → rotator_rulesource → ppc_account
--ipstringOnly clicks from this one IP address, IPv4 or IPv6
--isp-idstringFilter by ISP/carrier ID (the id of a --breakdown isp row)
--keywordstringOnly clicks whose keyword contains this text (case-insensitive)
--landing-page-idstringFilter by landing page ID
--limit, -lstringMax results
--method-of-promotionstringOnly direct-link clicks or only landing-page clicks: directlink, landingpage
directlinklandingpage
--offset, -ostringPagination offset
--periodstringPeriod: today, yesterday, last7, last14, last30, last90, thismonth, lastmonth, thisyear, lastyear, alltime
todayyesterdaylast7last14last30last90thismonthlastmonththisyearlastyearalltime
--platform-idstringFilter by platform (OS) ID (the id of a --breakdown platform row)
--ppc-account-idstringFilter by PPC account ID
--ppc-network-idstringFilter by PPC network ID, or none for the clicks with no traffic source
--refererstringOnly clicks whose referring URL contains this text (case-insensitive)
--region-idstringFilter by region ID (the id of a --breakdown region row)
--showstringWhich clicks count (default all): all, real, filtered, filtered_bot, leads; real = not filtered, filtered_bot = filtered as bots, leads = converted
allrealfilteredfiltered_botleads
--sortstringSort by: total_clicks, total_click_throughs, total_leads, total_income, total_cost, total_net, epc, avg_cpc, conv_rate, roi, cpa, clicks_per_day, conversions_per_day, revenue_per_day (aliases: clicks=total_clicks, conversions=total_leads, cost=total_cost, profit=total_net, revenue=total_income)
total_clickstotal_click_throughstotal_leadstotal_incometotal_costtotal_netepcavg_cpcconv_rateroicpaclicks_per_dayconversions_per_dayrevenue_per_dayclicks → total_clicksconversions → total_leadscost → total_costprofit → total_netrevenue → total_income
--sort-dirstringSort direction: ASC, DESC
ASCDESC
--split-atstringCompare before/after this moment: YYYY-MM-DD (00:00 UTC) or unix seconds. Splits the window (--days N, or --time-from/--time-to in unix seconds; default --days 90) into [start, split) and [split, end] and returns one row per value: clicks/conversions/revenue before, after, change, change %, and per-day rates. --sort clicks|conversions|revenue[_per_day] ranks by absolute change (default clicks)
--text-ad-idstringFilter by text ad ID
--time-fromstringStart: unix seconds, a date (2026-10-01, from its first second in the account's timezone) or a time with its offset (2026-10-01T09:30:00Z)
--time-tostringEnd, inclusive: unix seconds, a date (2026-10-01, through its last second in the account's timezone) or a time with its offset

05How it works

Stats grouped by one dimension: the shorthand for p202 report breakdown.

With --split-at, compare before and after a date: each value's totals on both sides, the change, and the daily rate on each side, so two windows of different lengths compare fairly.

06For agents

Running this from an agent

  • Read the same facts as JSON: p202 commands analytics --json.
  • With AI_AGENT, CLAUDECODE or another agent variable set, output is compact JSON and errors arrive on stderr as a JSON envelope with a hint.
  • Exit codes: 0 ok, 1 bad input, 2 auth, 3 network, 4 server error, 5 partial failure.
p202 commands analytics --json
{
  "path": "p202 analytics",
  "use": "analytics",
  "short": "Query performance stats grouped by campaign, traffic source, country, etc. (shorthand for report breakdown)",
  "long": "Stats grouped by one dimension: the shorthand for `p202 report breakdown`.\n\nWith --split-at, compare before and after a date: each value's totals on both\nsides, the change, and the daily rate on each side, so two windows of different\nlengths compare fairly.",
  "runnable": true,
  "example": "p202 analytics --group-by country --period last30\n  p202 analytics --group-by country --split-at 2026-09-04",
  "flags": [
    {
      "name": "aff-campaign-id",
      "type": "string",
      "default": "",
      "usage": "Filter by INTERNAL campaign id (from `campaign list`), not the public id in tracking URLs",
      "required": false
    },
    {
      "name": "aff-network-id",
      "type": "string",
      "default": "",
      "usage": "Filter by affiliate network ID",
      "required": false
    },
    {
      "name": "browser-id",
      "type": "string",
      "default": "",
      "usage": "Filter by browser ID (the id of a `--breakdown browser` row)",
      "required": false
    },
    {
      "name": "country-id",
      "type": "string",
      "default": "",
      "usage": "Filter by country ID",
      "required": false
    },
    {
      "name": "days",
      "type": "int",
      "default": "0",
      "usage": "Relative window: the last N×24 hours, ending now (ignored when --period is provided; --period lastN counts whole days from a midnight)",
      "required": false
    },
    {
      "name": "device-type",
      "type": "string",
      "default": "",
      "usage": "Filter by device type ID: 1 Desktop, 2 Mobile, 3 Tablet, 4 Bot (the ids of `--breakdown device_type` rows)",
      "required": false
    },
    {
      "name": "group-by",
      "type": "string",
      "default": "",
      "usage": "Breakdown dimension: campaign, aff_network, ppc_account, ppc_network, landing_page, keyword, country, city, region, browser, platform, device, isp, text_ad, ip, referer, referer_url, device_type, c1, c2, c3, c4, utm_source, utm_medium, utm_campaign, utm_term, utm_content, rotator, rotator_rule (aliases: geo=country, lp=landing_page, network=aff_network, offer=campaign, referrer=referer, referrer_url=referer_url, rule=rotator_rule, source=ppc_account)",
      "allowed_values": [
        "campaign",
        "aff_network",
        "ppc_account",
        "ppc_network",
        "landing_page",
        "keyword",
        "country",
        "city",
        "region",
        "browser",
        "platform",
        "device",
        "isp",
        "text_ad",
        "ip",
        "referer",
        "referer_url",
        "device_type",
        "c1",
        "c2",
        "c3",
        "c4",
        "utm_source",
        "utm_medium",
        "utm_campaign",
        "utm_term",
        "utm_content",
        "rotator",
        "rotator_rule"
      ],
      "value_aliases": {
        "geo": "country",
        "lp": "landing_page",
        "network": "aff_network",
        "offer": "campaign",
        "referrer": "referer",
        "referrer_url": "referer_url",
        "rule": "rotator_rule",
        "source": "ppc_account"
      },
      "required": false
    },
    {
      "name": "ip",
      "type": "string",
      "default": "",
      "usage": "Only clicks from this one IP address, IPv4 or IPv6",
      "required": false
    },
    {
      "name": "isp-id",
      "type": "string",
      "default": "",
      "usage": "Filter by ISP/carrier ID (the id of a `--breakdown isp` row)",
      "required": false
    },
    {
      "name": "keyword",
      "type": "string",
      "default": "",
      "usage": "Only clicks whose keyword contains this text (case-insensitive)",
      "required": false
    },
    {
      "name": "landing-page-id",
      "type": "string",
      "default": "",
      "usage": "Filter by landing page ID",
      "required": false
    },
    {
      "name": "limit",
      "shorthand": "l",
      "type": "string",
      "default": "",
      "usage": "Max results",
      "required": false
    },
    {
      "name": "method-of-promotion",
      "type": "string",
      "default": "",
      "usage": "Only direct-link clicks or only landing-page clicks: directlink, landingpage",
      "allowed_values": [
        "directlink",
        "landingpage"
      ],
      "required": false
    },
    {
      "name": "offset",
      "shorthand": "o",
      "type": "string",
      "default": "",
      "usage": "Pagination offset",
      "required": false
    },
    {
      "name": "period",
      "type": "string",
      "default": "",
      "usage": "Period: today, yesterday, last7, last14, last30, last90, thismonth, lastmonth, thisyear, lastyear, alltime",
      "allowed_values": [
        "today",
        "yesterday",
        "last7",
        "last14",
        "last30",
        "last90",
        "thismonth",
        "lastmonth",
        "thisyear",
        "lastyear",
        "alltime"
      ],
      "required": false
    },
    {
      "name": "platform-id",
      "type": "string",
      "default": "",
      "usage": "Filter by platform (OS) ID (the id of a `--breakdown platform` row)",
      "required": false
    },
    {
      "name": "ppc-account-id",
      "type": "string",
      "default": "",
      "usage": "Filter by PPC account ID",
      "required": false
    },
    {
      "name": "ppc-network-id",
      "type": "string",
      "default": "",
      "usage": "Filter by PPC network ID, or none for the clicks with no traffic source",
      "required": false
    },
    {
      "name": "referer",
      "type": "string",
      "default": "",
      "usage": "Only clicks whose referring URL contains this text (case-insensitive)",
      "required": false
    },
    {
      "name": "region-id",
      "type": "string",
      "default": "",
      "usage": "Filter by region ID (the id of a `--breakdown region` row)",
      "required": false
    },
    {
      "name": "show",
      "type": "string",
      "default": "",
      "usage": "Which clicks count (default all): all, real, filtered, filtered_bot, leads; real = not filtered, filtered_bot = filtered as bots, leads = converted",
      "allowed_values": [
        "all",
        "real",
        "filtered",
        "filtered_bot",
        "leads"
      ],
      "required": false
    },
    {
      "name": "sort",
      "type": "string",
      "default": "",
      "usage": "Sort by: total_clicks, total_click_throughs, total_leads, total_income, total_cost, total_net, epc, avg_cpc, conv_rate, roi, cpa, clicks_per_day, conversions_per_day, revenue_per_day (aliases: clicks=total_clicks, conversions=total_leads, cost=total_cost, profit=total_net, revenue=total_income)",
      "allowed_values": [
        "total_clicks",
        "total_click_throughs",
        "total_leads",
        "total_income",
        "total_cost",
        "total_net",
        "epc",
        "avg_cpc",
        "conv_rate",
        "roi",
        "cpa",
        "clicks_per_day",
        "conversions_per_day",
        "revenue_per_day"
      ],
      "value_aliases": {
        "clicks": "total_clicks",
        "conversions": "total_leads",
        "cost": "total_cost",
        "profit": "total_net",
        "revenue": "total_income"
      },
      "required": false
    },
    {
      "name": "sort-dir",
      "type": "string",
      "default": "",
      "usage": "Sort direction: ASC, DESC",
      "allowed_values": [
        "ASC",
        "DESC"
      ],
      "required": false
    },
    {
      "name": "split-at",
      "type": "string",
      "default": "",
      "usage": "Compare before/after this moment: YYYY-MM-DD (00:00 UTC) or unix seconds. Splits the window (--days N, or --time-from/--time-to in unix seconds; default --days 90) into [start, split) and [split, end] and returns one row per value: clicks/conversions/revenue before, after, change, change %, and per-day rates. --sort clicks|conversions|revenue[_per_day] ranks by absolute change (default clicks)",
      "required": false
    },
    {
      "name": "text-ad-id",
      "type": "string",
      "default": "",
      "usage": "Filter by text ad ID",
      "required": false
    },
    {
      "name": "time-from",
      "type": "string",
      "default": "",
      "usage": "Start: unix seconds, a date (2026-10-01, from its first second in the account's timezone) or a time with its offset (2026-10-01T09:30:00Z)",
      "required": false
    },
    {
      "name": "time-to",
      "type": "string",
      "default": "",
      "usage": "End, inclusive: unix seconds, a date (2026-10-01, through its last second in the account's timezone) or a time with its offset",
      "required": false
    }
  ]
}