Analytics
Event tracking, search, and reporting
Track user events, search content, and access platform analytics.
Analytics & Search
Comprehensive event tracking, full-text search across all content, and advanced reporting for data-driven insights.
Overview
The Analytics Service provides:
- Event tracking
- Search functionality
- User activity timelines
- Dashboard analytics
- Funnel analysis
Base Paths:
- Analytics:
/v1/analytics - Search:
/v1/search
Event Tracking
Track Single Event
POST /v1/analytics/track{
"eventName": "page.view",
"eventType": "navigation",
"metadata": {
"page": "/dashboard",
"referrer": "/login",
"device": "mobile"
}
}Track Bulk Events
POST /v1/analytics/track/bulk{
"events": [
{
"eventName": "button.click",
"eventType": "interaction",
"metadata": { "button": "buy_now" }
},
{
"eventName": "form.submit",
"eventType": "conversion",
"metadata": { "form": "signup" }
}
]
}Get User Events
GET /v1/analytics/events| Parameter | Type | Description |
|---|---|---|
| page | number | Page number |
| limit | number | Results per page |
| eventType | string | Filter by type |
| startDate | datetime | Start date |
| endDate | datetime | End date |
{
"success": true,
"status": 200,
"data": [
{
"id": "event_123",
"userId": "user_456",
"eventName": "trade.created",
"eventType": "trading",
"metadata": {
"tradeId": "trade_789",
"symbol": "EUR/USD"
},
"timestamp": "2025-10-21T12:00:00.000Z"
}
],
"pagination": {...}
}Search
Search All Content
GET /v1/search| Parameter | Type | Required | Description |
|---|---|---|---|
| q | string | Yes | Search query |
| type | string | No | Filter by type (post, course, trade, user) |
| page | number | No | Page number |
| limit | number | No | Results per page |
Example:
# Development
curl "https://api-gateway.dev.1houseglobalservices.com/v1/search?q=EUR/USD&type=post" \
-H "X-API-Key: your-development-api-key" \
-H "Authorization: Bearer your-jwt-token"
# Production
curl "https://api-gateway.prod.1houseglobalservices.com/v1/search?q=EUR/USD&type=post" \
-H "X-API-Key: your-production-api-key" \
-H "Authorization: Bearer your-jwt-token"{
"success": true,
"status": 200,
"data": {
"results": [
{
"type": "post",
"id": "post_123",
"title": "EUR/USD Analysis",
"excerpt": "...EUR/USD breaking resistance at 1.0950...",
"url": "/posts/post_123",
"score": 0.95,
"createdAt": "2025-10-21T10:00:00.000Z"
},
{
"type": "course",
"id": "course_456",
"title": "EUR/USD Trading Masterclass",
"excerpt": "Learn to trade EUR/USD like a pro",
"url": "/courses/course_456",
"score": 0.87,
"createdAt": "2025-01-15T00:00:00.000Z"
}
],
"totalResults": 45
},
"pagination": {
"page": 1,
"limit": 10,
"total": 45,
"pages": 5
}
}Get Search Suggestions
GET /v1/search/suggestions?q=eur{
"success": true,
"status": 200,
"data": [
"EUR/USD",
"EUR/USD trading strategies",
"EUR/USD analysis",
"EUR/GBP",
"European Central Bank"
]
}Get Search History
GET /v1/search/history{
"success": true,
"status": 200,
"data": [
{
"query": "EUR/USD analysis",
"resultCount": 45,
"searchedAt": "2025-10-21T12:00:00.000Z"
}
]
}Dashboard Analytics (Admin)
Get Dashboard Data
GET /v1/analytics/dashboard| Parameter | Type | Description |
|---|---|---|
| period | string | 7d, 30d, 90d, 1y |
{
"success": true,
"status": 200,
"data": {
"overview": {
"totalUsers": 12500,
"activeUsers": 3456,
"newUsers": 234,
"totalRevenue": 45678.00
},
"traffic": {
"pageViews": 156789,
"uniqueVisitors": 8901,
"averageSessionDuration": 420
},
"engagement": {
"postsCreated": 456,
"commentsPosted": 1234,
"reactionsGiven": 5678
},
"trading": {
"tradesCreated": 789,
"tradesWon": 512,
"winRate": 64.89
},
"education": {
"coursesCompleted": 234,
"lessonsWatched": 3456,
"totalWatchTime": 123456
}
}
}User Activity
Get Activity Timeline
GET /v1/analytics/user/activity| Parameter | Type | Description |
|---|---|---|
| days | number | Number of days (default: 30) |
{
"success": true,
"status": 200,
"data": [
{
"date": "2025-10-21",
"events": 45,
"breakdown": {
"page.view": 20,
"trade.created": 3,
"post.created": 2,
"course.viewed": 5
}
}
]
}Get User Statistics
GET /v1/analytics/user/stats{
"success": true,
"status": 200,
"data": {
"totalEvents": 1234,
"eventsThisWeek": 89,
"eventsThisMonth": 345,
"mostCommonEvents": [
{ "eventName": "page.view", "count": 567 },
{ "eventName": "trade.created", "count": 89 }
],
"engagement": {
"posts": 12,
"comments": 45,
"reactions": 123
},
"trading": {
"trades": 34,
"winRate": 67.65
},
"education": {
"coursesEnrolled": 5,
"lessonsCompleted": 89
}
}
}Funnel Analysis (Admin)
Analyze Conversion Funnel
POST /v1/analytics/funnel{
"eventSequence": [
"page.view.pricing",
"button.click.signup",
"form.submit.signup",
"payment.completed"
],
"startDate": "2025-10-01",
"endDate": "2025-10-21"
}{
"success": true,
"status": 200,
"data": {
"funnel": [
{
"step": "page.view.pricing",
"count": 1000,
"percentage": 100,
"dropoff": 0
},
{
"step": "button.click.signup",
"count": 450,
"percentage": 45,
"dropoff": 55
},
{
"step": "form.submit.signup",
"count": 380,
"percentage": 38,
"dropoff": 7
},
{
"step": "payment.completed",
"count": 234,
"percentage": 23.4,
"dropoff": 14.6
}
],
"conversionRate": 23.4,
"totalUsers": 1000
}
}Aggregated Analytics (Admin)
Get Event Aggregates
GET /v1/analytics/aggregate| Parameter | Type | Description |
|---|---|---|
| groupBy | string | day, week, month |
| eventType | string | Filter by event type |
| eventName | string | Filter by event name |
| startDate | datetime | Start date |
| endDate | datetime | End date |
Get Event Counts by Type
GET /v1/analytics/events/types{
"success": true,
"status": 200,
"data": [
{ "eventType": "trading", "count": 456 },
{ "eventType": "education", "count": 789 },
{ "eventType": "navigation", "count": 1234 },
{ "eventType": "engagement", "count": 567 }
]
}Get Popular Events
GET /v1/analytics/events/popular{
"success": true,
"status": 200,
"data": [
{ "eventName": "page.view", "count": 12345 },
{ "eventName": "trade.created", "count": 456 },
{ "eventName": "course.viewed", "count": 789 }
]
}Common Events to Track
Navigation
page.view- Page viewsection.scroll- Scrolled to sectionexit.intent- User about to leave
Engagement
button.click- Button clickedform.submit- Form submittedvideo.play- Video startedvideo.complete- Video finished
Trading
trade.created- New tradetrade.viewed- Trade idea viewedmarket.searched- Symbol searched
Education
course.viewed- Course page viewlesson.started- Lesson playback startedlesson.completed- Lesson finishedcourse.enrolled- User enrolled
Conversion
signup.started- Signup form openedsignup.completed- Account createdpayment.initiated- Checkout startedpayment.completed- Purchase made
Client-Side Tracking
// Tracking utility
class AnalyticsTracker {
constructor(apiKey, token) {
this.apiKey = apiKey;
this.token = token;
this.queue = [];
this.flushInterval = 10000; // 10 seconds
setInterval(() => this.flush(), this.flushInterval);
}
track(eventName, eventType, metadata = {}) {
this.queue.push({
eventName,
eventType,
metadata,
timestamp: new Date().toISOString()
});
// Flush if queue gets large
if (this.queue.length >= 10) {
this.flush();
}
}
async flush() {
if (this.queue.length === 0) return;
const events = [...this.queue];
this.queue = [];
await fetch('/v1/analytics/track/bulk', {
method: 'POST',
headers: {
'X-API-Key': this.apiKey,
'Authorization': `Bearer ${this.token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ events })
});
}
}
// Usage
const tracker = new AnalyticsTracker(apiKey, token);
// Track page view
tracker.track('page.view', 'navigation', { page: '/dashboard' });
// Track button click
document.getElementById('tradeBtn').addEventListener('click', () => {
tracker.track('button.click', 'interaction', { button: 'create_trade' });
});
// Track form submit
form.addEventListener('submit', () => {
tracker.track('form.submit', 'conversion', { form: 'signup' });
});Related Documentation
- Search API - Advanced search features
- Reporting - Generate reports
- Events - Event schema reference