Key Features
- Zero PII storage — no IP addresses, user agents, or visitor IDs in the database
- Aggregated daily counters — efficient storage in
_analyticscollection - Session ring buffer — 50 most recent visits in
_analytics_sessions - Automatic retention — 90 days for analytics, 50 records for sessions
- Bot filtering — excludes crawlers and automated traffic
- Device and browser detection — desktop/mobile/tablet classification
How It Works
Request Tracking
Fromcore/analytics/collector.go:34:
Privacy-First Design
Fromcore/analytics/analytics.go:11:
Data Collected
Daily Aggregated Counters (_analytics)
| Field | Type | Description |
|---|---|---|
path | text | Page path (e.g., /docs, /about) |
date | text | Date in YYYY-MM-DD format |
device_type | text | desktop, mobile, or tablet |
browser | text | Browser name (e.g., chrome, firefox) |
views | number | Total page views for this row |
unique_sessions | number | Count of new sessions |
(path, date, device_type, browser)
Recent Sessions (_analytics_sessions)
| Field | Type | Description |
|---|---|---|
path | text | Page path visited |
device_type | text | Device classification |
browser | text | Browser name |
os | text | Operating system |
timestamp | datetime | Visit time |
is_new_session | bool | Whether this was a new session |
What Is NOT Stored
✅ PII-free tracking:- ❌ No IP addresses
- ❌ No user agents
- ❌ No visitor IDs or cookies
- ❌ No session IDs
- ❌ No referrer URLs
- ❌ No query parameters
- ✅ Only aggregated counts and device metadata
Device and Browser Detection
Fromcore/analytics/collector.go:156:
Excluded Paths
Fromcore/analytics/collector.go:204:
The following paths are automatically excluded from tracking:
- Images:
.png,.jpg,.jpeg,.gif,.svg,.ico,.webp, etc. - Scripts/Styles:
.css,.js,.json,.map,.webmanifest - Media:
.mp4,.webm,.mp3,.wav, etc. - Documents:
.pdf,.doc,.xls,.txt, etc. - Archives:
.zip,.rar,.7z,.tar,.gz - Fonts:
.woff,.woff2,.ttf,.eot,.otf
Bot Filtering
Fromcore/analytics/collector.go:226:
Data Retention
Analytics Counters
Fromcore/analytics/types.go:7:
__pbExtAnalyticsClean__ system job)
Session Ring Buffer
Fromcore/analytics/types.go:10:
Session Window
Fromcore/analytics/analytics.go:28:
Analytics Data Structure
Fromcore/analytics/types.go:14:
Session Cleanup
Fromcore/analytics/analytics.go:47:
Middleware Registration
Fromcore/analytics/collector.go:15:
Dashboard Integration
View analytics in the pb-ext dashboard at/_/_:
- Total page views (today vs. yesterday)
- Unique visitors and session counts
- Device type breakdown (desktop/mobile/tablet)
- Browser distribution
- Top pages by view count
- Recent visitor activity (last 50 visits)
- Hourly activity trends
GDPR Compliance
pb-ext analytics is designed to be GDPR-compliant: ✅ No consent banner required — no personal data is stored✅ No cookies — tracking is server-side only
✅ No tracking scripts — no client-side JavaScript
✅ Aggregated data only — individual visitors cannot be identified
✅ Automatic retention — old data is automatically purged
✅ Transparent — all source code is open and auditable
Best Practices
- Review excluded paths to ensure admin/API routes aren’t tracked
- Monitor session cleanup to prevent memory growth
- Check bot patterns if you see unusual traffic
- Use the 90-day window for trend analysis
- Export data periodically if you need longer retention
Custom Analytics Queries
Query the_analytics collection directly for custom reports:
Related
- Monitoring - System metrics tracking
- Dashboard - View analytics UI
- Cron Jobs - Analytics cleanup job