$npx -y skills add 40RTY-ai/shopify-admin-skills --skill shopify-admin-sales-by-channel-reportRead-only: breaks down revenue, units, and AOV by sales channel (Online Store, POS, Draft Orders, etc.).
| 1 | ## Purpose |
| 2 | Analyzes orders by their source channel to produce a revenue, units sold, and AOV breakdown per channel. Helps multi-channel merchants understand where revenue is coming from — Online Store, POS, Draft Orders (B2B), mobile app, or third-party channels. Read-only — no mutations. |
| 3 | |
| 4 | ## Prerequisites |
| 5 | - Authenticated Shopify CLI session: `shopify store auth --store <domain> --scopes read_orders` |
| 6 | - API scopes: `read_orders` |
| 7 | |
| 8 | ## Parameters |
| 9 | |
| 10 | | Parameter | Type | Required | Default | Description | |
| 11 | |-----------|------|----------|---------|-------------| |
| 12 | | store | string | yes | — | Store domain (e.g., mystore.myshopify.com) | |
| 13 | | days_back | integer | no | 30 | Lookback window | |
| 14 | | format | string | no | human | Output format: `human` or `json` | |
| 15 | |
| 16 | ## Safety |
| 17 | |
| 18 | > ℹ️ Read-only skill — no mutations are executed. Safe to run at any time. |
| 19 | |
| 20 | ## Workflow Steps |
| 21 | |
| 22 | 1. **OPERATION:** `orders` — query |
| 23 | **Inputs:** `query: "created_at:>='<NOW - days_back days>'"`, `first: 250`, select `channelInformation { channelDefinition { handle, displayName } }`, `totalPriceSet`, `lineItems { quantity }`, pagination cursor |
| 24 | **Expected output:** Orders with channel attribution; paginate until `hasNextPage: false` |
| 25 | |
| 26 | 2. Group by `channel.displayName`; calculate per-channel: order count, total revenue, total units, AOV |
| 27 | |
| 28 | ## GraphQL Operations |
| 29 | |
| 30 | ```graphql |
| 31 | # orders:query — validated against api_version 2025-01 |
| 32 | query OrdersByChannel($query: String!, $after: String) { |
| 33 | orders(first: 250, after: $after, query: $query) { |
| 34 | edges { |
| 35 | node { |
| 36 | id |
| 37 | name |
| 38 | createdAt |
| 39 | totalPriceSet { |
| 40 | shopMoney { |
| 41 | amount |
| 42 | currencyCode |
| 43 | } |
| 44 | } |
| 45 | channelInformation { |
| 46 | channelDefinition { |
| 47 | handle |
| 48 | displayName |
| 49 | } |
| 50 | } |
| 51 | lineItems(first: 50) { |
| 52 | edges { |
| 53 | node { |
| 54 | quantity |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | pageInfo { |
| 61 | hasNextPage |
| 62 | endCursor |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | ``` |
| 67 | |
| 68 | ## Session Tracking |
| 69 | |
| 70 | **Claude MUST emit the following output at each stage. This is mandatory.** |
| 71 | |
| 72 | **On start**, emit: |
| 73 | ``` |
| 74 | ╔══════════════════════════════════════════════╗ |
| 75 | ║ SKILL: Sales by Channel Report ║ |
| 76 | ║ Store: <store domain> ║ |
| 77 | ║ Started: <YYYY-MM-DD HH:MM UTC> ║ |
| 78 | ╚══════════════════════════════════════════════╝ |
| 79 | ``` |
| 80 | |
| 81 | **After each step**, emit: |
| 82 | ``` |
| 83 | [N/TOTAL] <QUERY|MUTATION> <OperationName> |
| 84 | → Params: <brief summary of key inputs> |
| 85 | → Result: <count or outcome> |
| 86 | ``` |
| 87 | |
| 88 | **On completion**, emit: |
| 89 | |
| 90 | For `format: human` (default): |
| 91 | ``` |
| 92 | ══════════════════════════════════════════════ |
| 93 | SALES BY CHANNEL (<days_back> days) |
| 94 | Total revenue: $<amount> |
| 95 | Total orders: <n> |
| 96 | |
| 97 | Channel Orders Revenue AOV Units Share |
| 98 | ───────────────────────────────────────────────────────────── |
| 99 | Online Store <n> $<n> $<n> <n> <pct>% |
| 100 | POS <n> $<n> $<n> <n> <pct>% |
| 101 | Draft Orders <n> $<n> $<n> <n> <pct>% |
| 102 | Output: sales_by_channel_<date>.csv |
| 103 | ══════════════════════════════════════════════ |
| 104 | ``` |
| 105 | |
| 106 | For `format: json`, emit: |
| 107 | ```json |
| 108 | { |
| 109 | "skill": "sales-by-channel-report", |
| 110 | "store": "<domain>", |
| 111 | "period_days": 30, |
| 112 | "total_revenue": 0, |
| 113 | "total_orders": 0, |
| 114 | "currency": "USD", |
| 115 | "by_channel": [], |
| 116 | "output_file": "sales_by_channel_<date>.csv" |
| 117 | } |
| 118 | ``` |
| 119 | |
| 120 | ## Output Format |
| 121 | CSV file `sales_by_channel_<YYYY-MM-DD>.csv` with columns: |
| 122 | `channel_handle`, `channel_name`, `order_count`, `total_revenue`, `aov`, `total_units`, `revenue_share_pct`, `currency` |
| 123 | |
| 124 | ## Error Handling |
| 125 | | Error | Cause | Recovery | |
| 126 | |-------|-------|----------| |
| 127 | | `THROTTLED` | API rate limit exceeded | Wait 2 seconds, retry up to 3 times | |
| 128 | | Null channel info | Orders from deleted/unknown channels | Group under "Unknown" | |
| 129 | | No orders in window | Quiet period | Exit with 0 revenue | |
| 130 | |
| 131 | ## Best Practices |
| 132 | - POS orders with unusually low AOV compared to Online Store may indicate staff discount abuse or checkout errors — worth cross-referencing. |
| 133 | - Draft Orders channel represents B2B/wholesale orders — if growing, it may warrant a dedicated B2B reporting workflow. |
| 134 | - Channel mix changes over time signal where marketing spend is working — combine with `average-order-value-trends` for a full picture. |