Sessions & Bounce Rate
Track user sessions and measure engagement with bounce rate analytics. Understand how users interact with your application over time.
Overview
A session represents a continuous period of user activity. Sessions help you understand engagement depth, identify single-page bounces, and measure how long users spend in your application.
How Sessions Work
Session Tracking
Sessions are tracked automatically when you include a sessionId in your events:
{
"eventName": "page_view",
"userId": "user_123",
"sessionId": "sess_abc123",
"metadata": {
"url": "/pricing",
"referrer": "https://google.com"
}
}Session Lifecycle
- Session Start: First event with a sessionId creates the session
- Session Activity: Subsequent events update the session
- Session End: Session expires after 30 minutes of inactivity
Session Properties
Each session tracks:
- Pageviews: Number of events in the session
- Duration: Time from first to last event
- Entry Page: First page viewed in session
- Referrer: Traffic source that started the session
- Technology: Browser, OS, device, language
- Geography: Country, city (when available)
- Bounce Status: Whether the session had only one pageview
Bounce Rate
What is Bounce Rate?
Bounce rate is the percentage of sessions where users viewed only one page before leaving. A bounce indicates that the user didn't find what they were looking for or lost interest immediately.
Calculation
Bounce Rate = (Single-Pageview Sessions / Total Sessions) × 100Example
- Total Sessions: 1000
- Single-Pageview Sessions: 450
- Bounce Rate: 45%
How Bounces Are Determined
- Session starts with bounced = true
- Second pageview sets bounced = false
- Sessions with only one pageview remain bounced = true
Implementing Session Tracking
JavaScript Example
import { Serla } from './lib/serla';
const serla = new Serla('YOUR_API_KEY');
// Generate or retrieve session ID
function getSessionId() {
let sessionId = sessionStorage.getItem('serla_session_id');
if (!sessionId) {
sessionId = 'sess_' + Math.random().toString(36).substring(2, 15);
sessionStorage.getItem('serla_session_id', sessionId);
}
return sessionId;
}
// Track pageview with session
async function trackPageView(path) {
// Set session and user
serla.setSession(getSessionId());
serla.identify(getCurrentUserId());
// Track pageview
await serla.send('page_view', {
url: path,
referrer: document.referrer
});
}
// Track on every page load
trackPageView(window.location.pathname);Next.js Example
'use client';
import { useEffect } from 'react';
import { usePathname } from 'next/navigation';
import { Serla } from '@/lib/serla';
const serla = new Serla(process.env.NEXT_PUBLIC_SERLA_API_KEY!);
function getSessionId() {
if (typeof window === 'undefined') return null;
let sessionId = sessionStorage.getItem('serla_session_id');
if (!sessionId) {
sessionId = 'sess_' + Math.random().toString(36).substring(2, 15);
sessionStorage.setItem('serla_session_id', sessionId);
}
return sessionId;
}
export function Analytics() {
const pathname = usePathname();
useEffect(() => {
async function trackPageView() {
serla.setSession(getSessionId());
await serla.send('page_view', {
url: pathname,
referrer: document.referrer
});
}
trackPageView();
}, [pathname]);
return null;
}Viewing Session Data
Overview Dashboard
The Overview dashboard displays:
- Total Sessions: Session count for the period
- Bounce Rate: Percentage of single-pageview sessions
- Unique Visitors: Count of distinct users
Session List
View individual sessions with:
- Session duration
- Pageview count
- Entry page and referrer
- Device and location info
- Event timeline
Bounce Rate Benchmarks
Landing Pages
- Good: 26-40%
- Average: 41-55%
- Needs Improvement: 55%+
Content Pages
- Good: 40-60%
- Average: 61-75%
- Needs Improvement: 75%+
E-commerce
- Good: 20-40%
- Average: 41-55%
- Needs Improvement: 55%+
Blogs
- Good: 65-90%
- Average: Single-page visits are expected for blogs
Improving Bounce Rate
Common Causes of High Bounce Rate
- Slow page load: Users leave before content appears
- Poor mobile experience: Responsive design issues
- Misleading titles/ads: Content doesn't match expectations
- Lack of clear CTAs: Users don't know what to do next
- Technical issues: Broken pages or errors
- Wrong audience: Traffic from irrelevant sources
Optimization Strategies
1. Improve Page Load Speed
- Optimize images and assets
- Use CDN for faster delivery
- Minimize JavaScript bundle size
- Enable browser caching
2. Enhance Content Relevance
- Match headlines to ad copy and search intent
- Provide clear value proposition above the fold
- Use engaging visuals and formatting
- Update outdated content
3. Add Clear Navigation
- Include prominent calls-to-action
- Add internal links to related content
- Use sticky navigation menus
- Provide search functionality
4. Optimize for Mobile
- Use responsive design
- Make buttons and links touch-friendly
- Avoid pop-ups that block content
- Test on actual mobile devices
5. Target the Right Audience
- Review traffic sources and refine targeting
- Use negative keywords in paid campaigns
- Ensure ad copy matches landing page content
- Create dedicated landing pages for campaigns
Advanced Session Analysis
Session Duration
Average session duration indicates engagement depth:
- Short (0-30 sec): Users leave quickly, possible bounce
- Medium (30 sec - 3 min): Users are browsing
- Long (3+ min): Deep engagement with content
Pages per Session
Higher pages per session indicates:
- Engaging content that encourages exploration
- Effective internal linking
- Good information architecture
Entry Page Analysis
Track bounce rate by entry page to identify:
- High-performing landing pages
- Pages that need optimization
- Most effective traffic sources
Referrer Analysis
Compare bounce rates across referrers to:
- Identify high-quality traffic sources
- Optimize campaigns with high bounce rates
- Focus on channels that drive engaged users
Session Timeout
Default Timeout
Sessions expire after 30 minutes of inactivity. This means:
- Events 30+ minutes apart are considered separate sessions
- Users returning after timeout start a new session
- Duration is measured from first to last event within 30 min window
Custom Timeout (Coming Soon)
Future updates will support custom session timeout configurations per project.
Best Practices
Session ID Generation
- Generate session IDs client-side on first page load
- Store in sessionStorage (not localStorage)
- Use cryptographically random values
- Don't include PII in session IDs
Event Tracking
- Include sessionId in all events, not just pageviews
- Track meaningful interactions as events
- Capture entry page and referrer in metadata
- Send events in real-time for accurate session tracking
Analysis Tips
- Compare bounce rates across time periods
- Segment by traffic source, device, and location
- Focus on improving highest-traffic landing pages
- Monitor bounce rate after site changes
- Set goals for bounce rate reduction
API Reference
Session Data in Overview API
GET /api/stats/overview?projectId={id}
Response includes:
{
"stats": {
"totalSessions": 8943,
"bounceRate": 42.3,
"uniqueVisitors": 6721
}
}Track Events with Session
POST /api/events/ingest
{
"eventName": "page_view",
"sessionId": "sess_abc123",
"metadata": {
"url": "/page",
"referrer": "https://google.com"
}
}