Overview

The Sessions endpoint provides comprehensive session analytics data including visitor journeys, session durations, page views, and detailed session metadata. Perfect for understanding user behavior patterns, analyzing conversion paths, and building detailed user journey reports.

Track individual user sessions with full context including device information, geographic data, UTM parameters, and custom session properties.

Endpoint

GET https://app.usehardal.com/api/websites/{signalId}/sessions

Authentication

Include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Parameters

ParameterTypeRequiredDefaultDescription
signalIdstringYes-Your website signal ID (URL path)
limitintegerNo1000Number of sessions to return (pagination)
offsetintegerNo0Number of sessions to skip (pagination)
timeframestringNocustomTime period: today, yesterday, last7days, last30days, custom
startDatestringNo-Start date for timeframe (ISO format)
endDatestringNo-End date for timeframe (ISO format)
targetSignalIdstringNosignalIdTarget signal ID for analytics data
timezonestringNoEurope/IstanbulTimezone for date calculations (e.g., Asia/Istanbul)
isHybridbooleanNofalseWhether this is a hybrid/self-hosted signal

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: Go to your Hardal dashboard → select your signal → Settings → Security → API Keys.

Start with a simple request to get recent sessions:

Usage Examples

Response Fields

Session Object

  • id: Unique session identifier
  • visitorId: Unique visitor identifier (tracks user across sessions)
  • startedAt: Session start timestamp (formatted in specified timezone)
  • duration: Session duration in seconds (e.g., “180s” for 3 minutes)
  • pageViews: Number of page views in this session
  • events: Total number of events triggered in this session
  • pages: Array of unique page URLs visited during the session
  • browser: Browser name (Chrome, Safari, Firefox, Edge, etc.)
  • os: Operating system (Windows, macOS, Linux, iOS, Android)
  • device: Device type (Desktop, Mobile, Tablet)
  • country: Country name based on IP geolocation
  • fields: Custom session properties and UTM parameters

Session Fields Object

Contains custom session properties that may include:

  • utm_source: Traffic source (e.g., “google”, “twitter”, “newsletter”)
  • utm_medium: Traffic medium (e.g., “cpc”, “social”, “email”, “organic”)
  • utm_campaign: Campaign name (e.g., “summer_sale”, “product_launch”)
  • user_id: Authenticated user identifier (if user is logged in)
  • referrer: Original referrer URL
  • custom_field_1, custom_field_2: Any custom tracking parameters you’ve implemented

Pagination Object

  • total: Total number of sessions available for the query
  • limit: Number of sessions requested per page
  • offset: Number of sessions skipped (for pagination)
  • currentPage: Current page number (1-based indexing)
  • totalPages: Total number of pages available
  • hasMore: Boolean indicating if more sessions are available

Pagination Best Practices

The sessions endpoint supports efficient pagination:

# Navigate through pages
# Page 1: First 100 sessions
curl -X GET \
  "https://app.usehardal.com/api/websites/${SIGNAL_ID}/sessions?limit=100&offset=0" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Page 2: Next 100 sessions
curl -X GET \
  "https://app.usehardal.com/api/websites/${SIGNAL_ID}/sessions?limit=100&offset=100" \
  -H "Authorization: Bearer YOUR_API_KEY"

# Page 3: Next 100 sessions
curl -X GET \
  "https://app.usehardal.com/api/websites/${SIGNAL_ID}/sessions?limit=100&offset=200" \
  -H "Authorization: Bearer YOUR_API_KEY"

Performance Tips:

  • Use reasonable page sizes (10-200 sessions per request)
  • Default limit is 1000 sessions if not specified
  • Use hasMore field to determine if more pages exist
  • Sessions are ordered by startedAt timestamp (newest first)

Usage Notes

  • Session Duration: Calculated from first to last event in the session
  • Page Array: Contains unique URLs visited during the session (no duplicates)
  • Custom Fields: Session fields contain UTM parameters and custom properties when available
  • Timezone Handling: All timestamps are formatted according to the specified timezone
  • Default Limits: Maximum 1000 sessions per request if not specified
  • Ordering: Sessions are ordered by startedAt timestamp in descending order (newest first)
  • Minimum Duration: Sessions with zero duration are given a minimum duration of 1 second
  • Page Numbering: Pagination uses 1-based page numbering in the response