Overview
Thedomain endpoint retrieves the most active domain from the last hour of analytics data. This is useful for dashboards that need to automatically determine which domain to display analytics for, especially when tracking multiple sites.
Endpoint
Parameters
This endpoint takes no parameters and automatically determines the most active domain.SQL Query
The endpoint uses a two-stage approach to find the best domain:- Primary: Returns the domain with the most hits in the last hour (excluding localhost and empty domains)
- Fallback: If no activity in the last hour, returns any non-localhost domain from the data
- Uses
coalesceto prefer the active domain but fall back if needed
Response
Example Response
TypeScript Usage
Use Cases
Dashboard Initialization
Automatically determine which domain to show on dashboard load
Domain Selector
Pre-select the most active domain in a dropdown
Single-Domain Setup
Verify which domain is being tracked
Multi-Tenant Default
Determine the primary domain for a tenant
Notes
The endpoint strips the ‘www.’ prefix from domains using
domainWithoutWWW() to normalize domain names.This endpoint is particularly useful for dashboards that track multiple domains and need to intelligently select a default view.