Building Real-Time Analytics: From Data Chaos to Business Insights
How we built AnalyticsPro for tracking user behavior, conversion funnels, and revenue metrics in real-time. Technical architecture for processing millions of events per day.
"How many users signed up today?"
Simple question. But when you're processing 5 million events per day, the answer isn't simple.
AnalyticsPro solves this: real-time dashboards that turn data chaos into actionable insights.
The Analytics Challenge
Most businesses use Google Analytics. It's free, but it's not built for product analytics:
- 24-48 hour delay in data processing
- Sampled data (not 100% accurate)
- Limited customization (you get what Google gives you)
What We Built Instead
Real-time analytics with custom metrics, no sampling, and sub-second query times.
Core Features
-
Event Tracking
- Page views, button clicks, form submissions
- Custom events (
purchase_completed,trial_started) - User properties (plan, signup date, location)
-
Conversion Funnels
- Landing page → Signup → Trial → Purchase
- Drop-off rates at each step
- Cohort analysis (users who signed up in Jan vs Feb)
-
Revenue Analytics
- MRR (monthly recurring revenue)
- Churn rate
- Customer lifetime value (LTV)
The Technical Architecture
Data Collection
Client SDK (JavaScript/React Native):
analytics.track('button_clicked', {
button_id: 'signup_cta',
page: '/pricing',
timestamp: Date.now()
});
Server SDK (Node.js):
analytics.identify(userId, {
email: 'user@example.com',
plan: 'pro',
mrr: 99
});
Data Pipeline
- Ingest: Events sent to AWS Kinesis (1M events/sec capacity)
- Process: Lambda functions validate, enrich, aggregate
- Store:
- Hot data: Redis (last 24 hours)
- Warm data: PostgreSQL (last 90 days)
- Cold data: S3 (everything else)
- Query: GraphQL API serves dashboard
Database Schema
Events table (partitioned by date):
CREATE TABLE events (
id UUID PRIMARY KEY,
user_id UUID,
event_name VARCHAR(255),
properties JSONB,
timestamp TIMESTAMPTZ,
INDEX idx_user_time (user_id, timestamp),
INDEX idx_event_time (event_name, timestamp)
);
Aggregations table (pre-computed metrics):
CREATE TABLE daily_metrics (
date DATE,
metric_name VARCHAR(255),
value NUMERIC,
PRIMARY KEY (date, metric_name)
);
Performance Optimizations
1. Pre-Aggregation
Don't calculate "signups today" on every dashboard load. Pre-compute it:
// Runs every hour via cron
async function aggregateDailySignups() {
const count = await db.query(`
SELECT COUNT(*) FROM events
WHERE event_name = 'user_signed_up'
AND timestamp >= CURRENT_DATE
`);
await redis.set('signups_today', count);
}
2. Caching Strategy
- Redis for "dashboard opens" (1min TTL)
- CDN for historical reports (24hr TTL)
- Skip cache for custom date ranges
3. Sampling for Exploratory Queries
User exploring data? Sample 10% of events, instant results.
User exporting report? Process 100% of events, queue job.
Real-World Metrics
E-commerce client:
- 2.5M events/day
- 450K monthly active users
- Dashboard loads in 180ms
- Custom funnel queries in 800ms
The Dashboard
Built with React + Recharts:
- Line charts (DAU, MAU trends)
- Funnel visualizations
- Cohort retention heatmaps
- Revenue breakdowns
No-code query builder:
Show me [event: purchase_completed]
Where [user.plan = 'pro']
Grouped by [date]
Cost at Scale
AWS infrastructure for 5M events/day:
- Kinesis: $200/month
- Lambda: $150/month
- RDS (PostgreSQL): $300/month
- Redis: $100/month
- S3 (long-term storage): $50/month
Total: $800/month vs $2,000-5,000/month for Mixpanel/Amplitude
When to Build vs Buy
Buy (Mixpanel, Amplitude) if:
- You need it now
- Team < 10 people
- Budget > $2K/month
Build (AnalyticsPro) if:
- Custom metrics matter
- You want to own the data
- Long-term cost savings (break-even at ~18 months)
Lessons Learned
- Start simple. Track 5 events, not 50.
- Cache aggressively. Real-time doesn't mean re-compute every second.
- Visualizations matter. Good charts > raw numbers.
- Privacy first. Anonymize IP addresses, respect GDPR.
Need custom analytics for your app?
Explore AnalyticsPro
Ready to Build Something?
Let's discuss your next project. Mobile apps, AI integration, or custom development.
Written by AJ Patatanian
Senior full-stack engineer with expertise in React Native, AI/ML, and cloud architecture. Building production apps at SERA Industries.
More articles →Continue Reading
Serverless Architecture: AWS Lambda at Scale
How we handle 10M requests/day with AWS Lambda while keeping costs under $500/month. Optimization strategies for serverless computing.
Building the Future: Cross-Platform Development and AI Integration
From mobile gaming to enterprise security systems, explore how modern development patterns, AI integration, and cloud-native architecture are transforming software delivery. Real insights from building production apps.