Overview
Real-time endpoints provide live analytics data, allowing you to monitor current website activity, active visitors, and real-time metrics.
Real-time Endpoints
Usage Examples
Get Active Visitors (Last 5 Minutes)
GET /api/websites/abc123/active?minutes=5
Get Active Visitors (Last 30 Minutes)
GET /api/websites/abc123/active?minutes=30
Get Real-time Metrics
GET /api/websites/abc123/metrics?minutes=5
Get Real-time Chart Data
GET /api/websites/abc123/chart-data?minutes=30&interval=minute&metric=pageviews
Real-time Data Features
Each active visitor includes:
- Session ID: Unique session identifier
- Current Page: Page they’re currently viewing
- Referrer: How they arrived at your site
- Technology: Browser, OS, device type
- Location: Country/region
- Duration: Time spent on current page
- Last Seen: Timestamp of last activity
Real-time Breakdowns
Active visitor data includes breakdowns by:
- Pages: Most viewed pages right now
- Referrers: Traffic sources for active visitors
- Devices: Device types of active visitors
- Countries: Geographic distribution
Time Windows
Real-time data supports two time windows:
- 5 minutes: Ultra-recent activity
- 30 minutes: Recent activity with more data
Real-time Monitoring Use Cases
Live Dashboard
# Get comprehensive real-time overview
GET /api/websites/abc123/active?minutes=5
# Get minute-by-minute trends
GET /api/websites/abc123/chart-data?minutes=30&interval=minute
Content Performance Monitoring
# See which pages are being viewed right now
GET /api/websites/abc123/active?minutes=5
# Look at the "pages" array in response
Traffic Source Analysis
# Monitor real-time traffic sources
GET /api/websites/abc123/active?minutes=5
# Check "referrers" array for current traffic sources
Geographic Monitoring
# See where visitors are coming from right now
GET /api/websites/abc123/active?minutes=5
# Check "countries" array for geographic distribution
Real-time Alerts and Monitoring
Traffic Spikes: Monitor the count
field in active visitors to detect traffic spikes.
Page Performance: Watch the pages
array to see which content is performing well in real-time.
Campaign Monitoring: Use the referrers
data to monitor campaign performance as it happens.
Real-time data updates every minute. For the most current data, poll these endpoints at 1-minute intervals.
Integration Examples
JavaScript Real-time Dashboard
// Poll active visitors every minute
setInterval(async () => {
const response = await fetch('/api/websites/abc123/active?minutes=5', {
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const data = await response.json();
updateDashboard(data);
}, 60000); // Update every minute
Real-time Alerts
// Monitor for traffic spikes
const checkTrafficSpike = async () => {
const response = await fetch('/api/websites/abc123/active?minutes=5');
const data = await response.json();
if (data.count > 100) { // Alert if more than 100 active visitors
sendAlert(`Traffic spike detected: ${data.count} active visitors`);
}
};
Live Page Performance
// Monitor which pages are trending
const monitorTrendingPages = async () => {
const response = await fetch('/api/websites/abc123/active?minutes=5');
const data = await response.json();
const topPages = data.pages
.sort((a, b) => b.count - a.count)
.slice(0, 5);
console.log('Top pages right now:', topPages);
};