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.Global category ID to filter products
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.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
Caching Strategy
Caching Strategy
Analytics queries can be expensive. Consider implementing caching:
Pagination
Pagination
For large datasets, use the limit parameter:
Background Updates
Background Updates
Consider updating analytics in the background:
Error Handling
Category not found
Category not found
Status Code:
404No data available
No data available
Status Code:
200 (Success with empty data)Access denied
Access denied
Status Code:
403Analytics data is computed in real-time and reflects the current state of the marketplace. For historical analytics, consider implementing a separate data warehouse solution.
