Skip to main content

Endpoint

Get the count of events matching your filters. This endpoint is optimized for aggregations and is much faster than fetching all events just to count them.

Parameters

Path Parameters

Request Body

Filter Object

Response

Returns a simple count object:

When to Use Count vs Query

✅ Use Count Endpoint For:

  • Aggregations: Getting totals, averages, or other metrics
  • Dashboard widgets: Displaying numbers without needing event details
  • Performance monitoring: Checking if thresholds are exceeded
  • Quick checks: Verifying if events exist without fetching them

❌ Use Query Endpoint For:

  • Event details: When you need the actual event data
  • User journeys: Analyzing sequences of events
  • Data export: When you need to process individual events
  • Debugging: Investigating specific event properties

Examples

Basic Count

Count all page views in a date range:
Response:

Filtered Count

Count high-value purchases:

Multiple Filters

Count events from specific users on mobile devices:

Conversion Rate Calculation

Calculate conversion rates by comparing counts:

Code Examples

JavaScript/TypeScript

Python

Node.js

Dashboard Metrics

Use the count endpoint to build dashboard metrics:

Performance Monitoring

Monitor system health with count queries:

A/B Testing

Use count queries to analyze A/B test results:

Error Handling

Handle count query errors gracefully:

Performance Tips

1. Use Date Ranges

Always include date ranges to limit the data scanned:

2. Be Specific with Filters

Use specific filters to reduce the dataset:

3. Cache Results

Cache count results for frequently accessed metrics:

Custom Plans

Need higher rate limits for your count queries? We offer custom plans with:
  • Higher rate limits: Custom requests per minute/day limits
  • Dedicated support: Priority support and SLA guarantees
  • Volume discounts: Competitive pricing for high-volume usage
Contact us at support@grainql.com to discuss your requirements.

Next Steps

Query Events

Learn how to query events with filters

List Events

Discover available event types

Filter Reference

Complete guide to all filter operators

Custom Dashboard

Build a custom analytics dashboard