---
title: "Shortlink System"
description: "URL shortener with analytics and custom domains"
---
# Shortlink System
A comprehensive URL shortening solution with analytics and custom domain support.
## Features
- Create short URLs from long URLs
- Custom paths (e.g., `yoursite.com/my-link`)
- Preview images for social media
- Click analytics (countries, devices, referrers)
- Custom domain support
- Collision detection with existing routes
## Admin URL
| Page | URL |
|------|-----|
| Shortlink Management | `/admin/shortlinks` |
| Domain Management | `/admin/shortlinks/domains` |
## Creating a Shortlink
Go to `/admin/shortlinks`
Click **Create Shortlink**
Paste the long destination URL
- **Auto-generate**: Random short path
- **Custom**: Enter your own (e.g., `winter-sale`)
Upload an image for social media previews
Click **Create Shortlink**
## Analytics
Click the analytics icon on any shortlink to view:
| Metric | Description |
|--------|-------------|
| Total Clicks | Overall click count |
| Countries | Geographic distribution |
| Devices | Desktop, mobile, tablet breakdown |
| Referrers | Where clicks came from |
| Browsers | Browser usage stats |
Export analytics to CSV for further analysis.
## Custom Domains
### Setup Steps
Go to Domain Management → **Add Domain**
Enter subdomain (e.g., `link.yourdomain.com`)
Add these records in your DNS provider:
**CNAME Record:**
```
Name: link
Value: yourdomain.com
```
**TXT Record (for verification):**
```
Name: _shortlink-verify.link
Value: [verification token shown in dashboard]
```
Wait 5-10 minutes for DNS propagation, then click **Verify DNS**
Select the custom domain when creating new shortlinks
## Database Schema
### shortlinks Collection
```javascript
{
customPath: "winter-sale",
destinationUrl: "https://example.com/products?utm_source=...",
previewImageUrl: "https://...",
title: "Winter Sale 2024",
description: "50% off all items",
isActive: true,
clickCount: 150,
createdAt: "2024-01-01T00:00:00Z"
}
```
### shortlink_analytics Collection
```javascript
{
shortlinkId: "abc123",
timestamp: "2024-01-15T10:30:00Z",
country: "US",
countryName: "United States",
deviceType: "mobile",
browser: "Chrome",
referrer: "https://twitter.com"
}
```
## Collision Detection
The system automatically checks if your custom path conflicts with:
- Existing blog posts
- Project pages
- Static routes
- Other shortlinks
A warning appears if a collision is detected.
## Best Practices
Use descriptive paths like `winter-sale` instead of random strings for better memorability.
Add preview images to increase click-through rates by 30-50% on social media.
Shortlinks are case-insensitive. `My-Link` and `my-link` are the same.