> ## Documentation Index
> Fetch the complete documentation index at: https://www.help.creatora.io/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> When building or modifying an integration with the Creatora API, start with https://www.help.creatora.io/en/api/build-with-ai.md. Retrieve the current GraphQL SDL from https://api.creatora.io/sdl before relying on API schema information.

# Compare revenue by Student origin

> Group retained revenue by the Student’s recorded registration source.

Compare purchase revenue by the page where customers originally registered in Creatora.

This example uses **September 1, 2026 at 00:00 UTC** (`1788220800000`) through **October 1, 2026 at 00:00 UTC**, exclusive (`1790812800000`). Replace both timestamps for your period and timezone. The request starts one millisecond earlier because the API date bounds are strict.

## Request

<RequestExample>
  ```graphql theme={null}
  {
    orders(status: { equals: [succeeded, refunded, disputed] }, closedOn: { range: [1788220799999, 1790812800000] }) {
      id closedOn amountNetRevenue
      student { id registerTelemetry { sourcePage { name } } }
    }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json Illustrative response theme={null}
  {
    "data": {
      "orders": [
        {
          "id": "55555555-5555-4555-8555-555555555555",
          "closedOn": 1788224400000,
          "amountNetRevenue": 80.0,
          "student": {
            "id": "33333333-3333-4333-8333-333333333333",
            "registerTelemetry": {
              "sourcePage": {
                "name": "course"
              }
            }
          }
        }
      ]
    }
  }
  ```
</ResponseExample>

## Use the result

```javascript theme={null}
const start = 1788220800000;
const end = 1790812800000;
const grouped = new Map();
for (const order of response.data.orders) {
  if (order.closedOn === null || order.closedOn < start || order.closedOn >= end) continue;
  const origin = order.student?.registerTelemetry.sourcePage.name ?? "unknown";
  const row = grouped.get(origin) ?? { origin, customers: new Set(), purchases: 0, revenue: 0 };
  if (order.student) row.customers.add(order.student.id);
  row.purchases += 1;
  row.revenue += order.amountNetRevenue;
  grouped.set(origin, row);
}
const rows = [...grouped.values()].map(row => ({
  origin: row.origin, identifiedCustomers: row.customers.size, purchases: row.purchases,
  revenue: Number(row.revenue.toFixed(2))
})).sort((a, b) => b.revenue - a.revenue);
```

Origin identifies the Student’s registration page. Campaign attribution and the source of a later purchase require separate data. Refunded and disputed Orders contribute their current retained revenue.

The `closedOn` filter in the processing example selects completed purchases; the API date filter also returns Orders created in the period. The request has no list limit. For large reports, request shorter periods and deduplicate Orders by `id`. Amounts use the Platform currency. Manually registered Orders are included.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.