Skip to main content

Overview

The Analytics API provides comprehensive insights into marketplace performance, including product distribution, category analysis, and store metrics. These functions help administrators and stakeholders understand platform trends and make data-driven decisions. Location: convex/shared/analytics.ts

Get Product Counts by Global Category

Retrieves product counts grouped by global category across all stores in the marketplace.

Get Products by Global Category

Retrieves products within a specific global category with optional limit.
globalCategoryId
Id<'categories'>
required
Global category ID to filter products
limit
number
Maximum number of products to return (default: no limit)

Get Store Distribution by Global Category

Retrieves store distribution data showing how many products each store has in a specific global category.
globalCategoryId
Id<'categories'>
required
Global category ID to analyze

Analytics Dashboard Example

Here’s how you can build an analytics dashboard using these functions:

Use Cases

Platform Overview

Get high-level insights into marketplace performance and category distribution for executive dashboards.

Category Analysis

Analyze which categories are most popular and identify growth opportunities or oversaturated markets.

Store Performance

Compare store performance within categories to identify top performers and provide targeted support.

Market Research

Understand market trends and customer preferences to guide business strategy and store onboarding.

Real-time Analytics

All analytics functions return real-time data that updates automatically as the marketplace changes:

Performance Considerations

Analytics queries can be expensive. Consider implementing caching:
For large datasets, use the limit parameter:
Consider updating analytics in the background:

Error Handling

Status Code: 404
Status Code: 200 (Success with empty data)
Status Code: 403
Analytics data is computed in real-time and reflects the current state of the marketplace. For historical analytics, consider implementing a separate data warehouse solution.
Use the analytics functions to build comprehensive dashboards that help store owners and platform administrators make data-driven decisions.