Metrics API
Get comprehensive analytics metrics including time series data, visitor breakdowns, and totals
Overview
The Metrics endpoint provides comprehensive analytics data including time series charts, visitor breakdowns, and aggregated totals. Perfect for building dashboards, generating reports, and analyzing website performance across multiple dimensions.
Get detailed insights into your website traffic with support for custom timeframes, data intervals, timezone-aware calculations, and extensive visitor demographics.
Endpoint
Authentication
Include your API key in the Authorization header:
Parameters
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
signalId | string | Yes | - | Your website signal ID (URL path) |
timeframe | string | No | today | Time period: today , yesterday , last7days , last30days , custom |
interval | string | No | hourly | Data granularity: minute , hourly , daily , weekly , monthly |
targetSignalId | string | No | signalId | Target signal ID for analytics data |
timezone | string | No | UTC | Timezone for date calculations (e.g., Asia/Istanbul , America/New_York ) |
isHybrid | boolean | No | false | Whether this is a hybrid/self-hosted signal |
startDate | string | No | - | Start date for custom timeframe (ISO format) |
endDate | string | No | - | End date for custom timeframe (ISO format) |
Quick Start
Environment Setup
Finding your signal ID: Go to your Hardal dashboard → select your project → view the signal ID in the URL or settings.
Finding your API key: Navigate to your Hardal dashboard → select your signal → Settings → Security → API Keys.
Start with a basic request to get today’s metrics:
Basic Request
Basic Request
Get comprehensive metrics for today with hourly intervals.
Response:
Usage Examples
Today's Metrics (Hourly)
Today's Metrics (Hourly)
Perfect for real-time dashboards and current day analysis.
Response:
Use Case: Live dashboards, current day performance monitoring
Yesterday's Performance
Yesterday's Performance
Analyze complete previous day performance with hourly breakdowns.
Response:
Use Case: Daily reports, performance comparison, trend analysis
Weekly Trends (Last 7 Days)
Weekly Trends (Last 7 Days)
Get weekly performance with daily intervals for trend analysis.
Response:
Use Case: Weekly reporting, trend identification, content performance
Monthly Analytics (Last 30 Days)
Monthly Analytics (Last 30 Days)
Comprehensive monthly performance with daily granularity.
Response:
Use Case: Monthly reports, long-term trends, strategic planning
Custom Date Range
Custom Date Range
Analyze specific time periods with custom start and end dates.
Response:
Use Case: Campaign analysis, event-specific reporting, A/B testing
Response Fields
Timeseries Data
Each timeseries object contains:
date
: Timestamp for the data point (ISO format)pageviews
: Number of page views in this time periodvisitors
: Number of unique visitorssessions
: Number of unique sessionsbounce_rate
: Percentage of single-page sessionsavg_duration
: Average session duration in seconds
Visitor Breakdowns
Countries Array:
country
: Country namevisitors
: Number of unique visitors from this countrypercentage
: Percentage of total visitors
Browsers Array:
browser
: Browser name (Chrome, Safari, Firefox, etc.)visitors
: Number of unique visitors using this browserpercentage
: Percentage of total visitors
Operating Systems Array:
os
: Operating system name (Windows, macOS, Linux, etc.)visitors
: Number of unique visitors using this OSpercentage
: Percentage of total visitors
Devices Array:
device
: Device type (Desktop, Mobile, Tablet)visitors
: Number of unique visitors using this devicepercentage
: Percentage of total visitors
Content Performance
Pages Array:
path
: URL path of the pagetitle
: Page titlepageviews
: Number of page views for this pagevisitors
: Number of unique visitors to this pagepercentage
: Percentage of total traffic
Referrers Array:
referrer
: Referring domainvisitors
: Number of visitors from this referrerpercentage
: Percentage of total visitors
Totals Summary
pageviews
: Total page views in the selected periodvisitors
: Total unique visitorssessions
: Total unique sessionsbounce_rate
: Overall bounce rate percentageavg_duration
: Overall average session duration in secondsevents
: Total number of events (all types)
Timeframe Options
Preset Timeframes
Preset Timeframes
Today (today):
Current day from 00:00 to now
Yesterday (yesterday):
Previous day (full 24 hours)
Last 7 Days (last7days):
Last 7 days including today
Last 30 Days (last30days):
Last 30 days including today
Custom (custom):
Custom date range (requires startDate
and endDate
)
Data Intervals
Interval Options
Interval Options
Minute (minute):
Data points every minute (for real-time monitoring)
Hourly (hourly):
Data points every hour (default)
Daily (daily):
Data points every day (most common)
Weekly (weekly):
Data points every week
Monthly (monthly):
Data points every month
Best Practices
Performance Optimization
Performance Optimization
Choose appropriate intervals: Use hourly
for real-time dashboards, daily
for most reports, weekly
or monthly
for long-term analysis.
Limit date ranges: Shorter date ranges provide faster response times. For large datasets, consider breaking requests into smaller chunks.
Cache results: Implement caching for frequently accessed data to reduce API calls.
Timezone Considerations
Timezone Considerations
Always specify timezone: Use the timezone parameter to ensure consistent data interpretation.
Match user timezone: Use your users’ timezone or your business timezone for reporting.
Data Interpretation
Data Interpretation
Understanding bounce rate: Single-page sessions divided by total sessions. Lower is generally better.
Average duration: Excludes sessions with 0 duration. Longer sessions often indicate better engagement.
Percentage calculations: All percentages are calculated based on totals for each dimension.
Usage Notes
- All timestamps are returned in UTC, but calculations respect the specified timezone
- Results are limited to top entries (top 10 for most breakdowns, top 50 for countries)
- Bounce rate calculation: single-page sessions ÷ total sessions × 100
- Average duration excludes sessions with 0 duration for accuracy
- Real-time data updates every few minutes for current day metrics
- Historical data is processed and optimized for faster retrieval