Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ALEJ4NDRO2025/urban-store/llms.txt

Use this file to discover all available pages before exploring further.

The dashboard stats endpoint aggregates all behavioral event data from the last 7 days into a single response suitable for populating an admin analytics dashboard. Pass ?mode=unique to count distinct sessions instead of raw event totals — useful for deduplicating views across page reloads.

Endpoint

GET /api/analytics/dashboard-stats/

Authentication

Bearer token required with is_admin: true in the JWT payload. Returns 403 if the user is not an admin.

Query Parameters

mode
string
Controls how event counts are calculated.
  • total (default) — counts every event occurrence.
  • unique — counts distinct session_id values per event type.

Time Range

All metrics cover the last 7 days from the moment the request is made. Retention metrics (retention_metrics) use a 90-day lookback window.

Response Fields

mode
string
The active counting mode: "total" or "unique".
total_sales
integer
Total number of purchase events recorded in the 7-day window.
total_revenue
float
Sum of price × metadata.quantity across all purchase events. In COP.
average_order_value
float
total_revenue / total_sales. Returns 0 when there are no sales.
top_products
array
Top 5 products by units sold. Each entry: { "slug": string, "count": integer }.
top_viewed_products
array
Top 5 products by view count (unique views in mode=unique). Each entry: { "slug": string, "count": integer }.
sales_by_day
array
Daily purchase event counts. Each entry: { "date": "YYYY-MM-DD", "count": integer }. Sorted ascending by date.
events_timeline
array
One entry per day in the 7-day window, each containing daily counts for: product_view, add_to_cart, begin_checkout, purchase, checkout_started, payment_info_entered, order_completed.
abandonment_rate
float
Percentage of begin_checkout identifiers (user/session) that did not also fire a purchase event.
event_counts
object
Aggregate counts for funnel-critical event types. Keys: product_view, add_to_cart, begin_checkout, purchase. Respects the active mode.
conversion_rates
object
Funnel step conversion percentages. Keys:
  • visit_to_cart — add_to_cart / product_view
  • cart_to_checkout — begin_checkout / add_to_cart
  • checkout_to_purchase — purchase / begin_checkout
checkout_started_count
integer
Total checkout_started events in the window.
payment_info_entered_count
integer
Total payment_info_entered events in the window.
order_completed_count
integer
Total order_completed events in the window.
conversion_checkout_to_payment
float
payment_info_entered_count / checkout_started_count × 100.
conversion_payment_to_order
float
order_completed_count / payment_info_entered_count × 100.
error_counts
object
Error event totals. Keys: payment_error, checkout_error, payment_confirmation_error.
product_performance
array
Up to 10 products, sorted by views descending. Each entry: { slug, name, views, add_to_cart, purchases, conversion_rate }. In mode=unique, also includes purchases_units.
errors_timeline
array
One entry per day with daily counts for: payment_error, checkout_error, payment_confirmation_error, address_error.
session_stats
object
Session-level aggregates: unique_sessions, avg_events_per_session, sessions_with_purchase.
retention_metrics
object
90-day retention data: repurchase_rate (%), recurrent_customers, total_unique_buyers, period_days: 90.
traffic_sources
array
Sessions grouped by traffic source, sorted by session count descending. Each entry: { "source": string, "sessions": integer }. Null sources are reported as "direct".
whatsapp_sessions
integer
Unique sessions that fired a whatsapp_cart_click event in the 7-day window.
whatsapp_purchases
integer
Unique sessions that fired a whatsapp_purchase event in the 7-day window.
whatsapp_sessions_list
array
Last 10 unique session_id values that clicked the WhatsApp buy button.

Example

curl -X GET "https://api.urbanstore.co/api/analytics/dashboard-stats/?mode=unique" \
  -H "Authorization: Bearer <admin_token>"
{
  "mode": "unique",
  "total_sales": 38,
  "total_revenue": 7182000,
  "average_order_value": 189000,
  "top_products": [
    { "slug": "urban-cargo-pants", "count": 14 },
    { "slug": "oversized-hoodie", "count": 9 }
  ],
  "top_viewed_products": [
    { "slug": "urban-cargo-pants", "count": 220 },
    { "slug": "graphic-tee", "count": 185 }
  ],
  "sales_by_day": [
    { "date": "2024-05-16", "count": 4 },
    { "date": "2024-05-17", "count": 7 }
  ],
  "abandonment_rate": 34.5,
  "event_counts": {
    "product_view": 1240,
    "add_to_cart": 310,
    "begin_checkout": 89,
    "purchase": 38
  },
  "conversion_rates": {
    "visit_to_cart": 25.0,
    "cart_to_checkout": 28.7,
    "checkout_to_purchase": 42.7
  },
  "session_stats": {
    "unique_sessions": 540,
    "avg_events_per_session": 4.2,
    "sessions_with_purchase": 38
  },
  "retention_metrics": {
    "repurchase_rate": 18.4,
    "recurrent_customers": 7,
    "total_unique_buyers": 38,
    "period_days": 90
  },
  "traffic_sources": [
    { "source": "direct", "sessions": 220 },
    { "source": "google", "sessions": 180 }
  ],
  "whatsapp_sessions": 12,
  "whatsapp_purchases": 5,
  "whatsapp_sessions_list": ["abc123", "def456"]
}

Build docs developers (and LLMs) love