Overview
shrtnr automatically tracks every click on your short links, recording click counts and detailed analytics data. View total clicks in your dashboard and analyze traffic patterns to understand how your links perform.Analytics are available for all links, but only authenticated users can view their analytics in the dashboard.
What Gets Tracked
Every time someone clicks a short link, shrtnr records:Click Counter
- Total clicks: Incremented for each visit
- Displayed in dashboard: Shows total lifetime clicks per link
- Real-time updates: Click count updates immediately
Detailed Analytics
Each click stores:- IP Address: Visitor’s IP (from
x-forwarded-fororx-real-ipheaders) - User Agent: Browser and device information
- Referrer: Where the visitor came from (if available)
- Timestamp: When the click occurred (automatic)
Click recording happens asynchronously and won’t delay redirects. Even if analytics fail to record, the redirect still works.
Click Tracking Flow
When someone visits a short link:Viewing Analytics in Dashboard
Authenticated users can view click counts for all their links:Desktop Table View
The Clicks column shows total clicks with monospace formatting:Mobile Card View
Clicks appear in the link details below the URL:Analytics Data Points
IP Address
The visitor’s IP address is extracted from request headers:x-forwarded-for: If behind a proxy, take the first IP in the chainx-real-ip: Fallback header for reverse proxiesnull: If no IP headers are present
IP addresses are stored for analytics but are not displayed in the current dashboard UI. Future updates may include geographic analysis.
User Agent
The browser’s user agent string reveals:- Browser type and version (Chrome, Firefox, Safari, etc.)
- Operating system (Windows, macOS, iOS, Android)
- Device type (desktop, mobile, tablet)
Referrer
The referrer header shows where visitors came from:- Social media:
https://twitter.com/,https://facebook.com/ - Search engines:
https://www.google.com/search?q=... - Direct:
null(typed URL, bookmarked, or referrer blocked) - Email: Often null due to privacy protections
The HTTP header is spelled “referer” (misspelled in the HTTP spec), but some frameworks use “referrer” - shrtnr checks both.
Database Schema
URLs Table
Click counts are stored in the mainurls table:
Clicks Table
Detailed analytics are stored separately:Click Count Updates
The click counter uses an atomic increment:- No race conditions: Multiple simultaneous clicks increment correctly
- No read-modify-write: Direct SQL increment is faster and safer
- Accurate counts: Even under high traffic, counts remain accurate
Privacy Considerations
shrtnr respects visitor privacy while providing useful analytics:- IP addresses: Stored but not displayed; useful for fraud detection
- No cookies: shrtnr doesn’t set tracking cookies
- No fingerprinting: Only standard HTTP headers are used
- Anonymous clicks: Individual clicks aren’t linked to user accounts
Error Handling
Click recording is designed to never break redirects:- Non-blocking: Analytics failures are caught and logged
- Redirect continues: Even if click recording fails, users still get redirected
- Silent failure: Users never see analytics errors
Current Limitations
The current analytics implementation has some limitations:| Feature | Status | Notes |
|---|---|---|
| Total click count | ✅ Available | Shown in dashboard |
| Click history | ❌ Not accessible | Stored in DB but no UI |
| Geographic data | ❌ Not available | IP stored but not analyzed |
| Device breakdown | ❌ Not available | User agent stored but not parsed |
| Referrer analysis | ❌ Not available | Referrer stored but not displayed |
| Time-series data | ❌ Not available | Timestamps stored but no charts |
| Export to CSV | ❌ Not available | No export feature yet |
Future updates may include detailed analytics dashboards with charts, geographic maps, and device breakdowns.
Best Practices
Analytics Tips
- Monitor popular links: Check which links get the most clicks
- Track campaigns: Compare clicks across different custom slugs
- Watch for anomalies: Sudden spikes might indicate viral content or abuse
- Use custom slugs: Easier to identify links in your dashboard analytics
- Check before expiry: Review performance before links expire
Use Cases
Marketing Campaigns
Track which campaigns drive the most traffic:Social Media Performance
Compare engagement across platforms:Content Distribution
See which content resonates:Future Enhancements
Planned analytics features:- Click timeline: Visualize clicks over time with charts
- Geographic distribution: Map showing where clicks come from
- Device breakdown: Pie chart of desktop vs mobile vs tablet
- Referrer sources: Table of top traffic sources
- Export functionality: Download analytics as CSV or JSON
- Real-time dashboard: Live click notifications and counters
Interested in advanced analytics? Consider integrating with tools like Google Analytics or Plausible by adding tracking parameters to your original URLs.
Related Features
- Dashboard - View click counts and manage your links
- URL Shortening - All short links automatically track clicks
- Custom Slugs - Use memorable slugs to identify campaigns in analytics
- Link Expiration - Check performance before links expire