Purchases

The purchases metric measures the total number of completed purchase events within a given period. It is a key indicator of ecommerce performance and conversion outcomes.

Metric model

  • Name
    metric
    Type
    string
    Description

    Always purchases for this metric.

  • Name
    value
    Type
    integer
    Description

    Total number of purchases in the current period.

  • Name
    previous
    Type
    integer
    Description

    Purchase count from the previous period.

  • Name
    change
    Type
    float
    Description

    Percent change compared to the previous period.

  • Name
    formattedValue
    Type
    string
    Description

    Formatted current period value.

  • Name
    formattedPrevious
    Type
    string
    Description

    Formatted previous period value.

  • Name
    period.id
    Type
    string
    Description

    Period ID (e.g., 7d).

  • Name
    period.name
    Type
    string
    Description

    Human-friendly name of the period.

  • Name
    periodRange.current.start
    Type
    string
    Description

    Start timestamp of the current period.

  • Name
    periodRange.current.end
    Type
    string
    Description

    End timestamp of the current period.

  • Name
    periodRange.previous.start
    Type
    string
    Description

    Start timestamp of the previous period.

  • Name
    periodRange.previous.end
    Type
    string
    Description

    End timestamp of the previous period.

  • Name
    performance.duration
    Type
    float
    Description

    Time taken to compute the metric in milliseconds.

  • Name
    performance.formatted
    Type
    string
    Description

    Formatted query performance (e.g., 768 ms).


GET/api/metrics/purchases

Retrieve purchases metric

This endpoint allows you to retrieve the number of purchases within a selected period.

Optional query parameters

  • Name
    period
    Type
    string
    Description

    The period to retrieve. Most common:

    • today – Today
    • yesterday – Yesterday
    • 7d – Last 7 days
    • 30d – Last 30 days
    • this_month – This month
    View full list of supported periods →

Request

GET
/api/metrics/purchases
curl -G http://localhost:3000/api/metrics/purchases \
  -H "Authorization: Bearer {token}" \
  -d period=7d

Response

{
  "metric": "purchases",
  "value": 253,
  "previous": 271,
  "change": -6.64,
  "formattedValue": "253",
  "formattedPrevious": "271",
  "period": {
    "id": "7d",
    "name": "Last 7 days"
  },
  "periodRange": {
    "current": {
      "start": "2025-03-16T08:50:55.026Z",
      "end": "2025-03-23T08:50:55.025Z"
    },
    "previous": {
      "start": "2025-03-09T08:50:55.027Z",
      "end": "2025-03-16T08:50:55.026Z"
    }
  },
  "performance": {
    "duration": 768.45,
    "formatted": "768 ms"
  }
}

Use cases

  • Track purchase volume over time
  • Monitor the impact of campaigns on sales
  • Detect seasonal trends and spikes
  • Calculate conversion and sales efficiency

Was this page helpful?