Analytics
The Relink API provides comprehensive analytics endpoints to track and analyze the performance of your smartlinks. Analytics data includes clicks, QR code scans, geographic information, device types, and more.
Analytics Endpoints
Get Smartlink Analytics
Endpoint: GET /api/v1/smartlink/analytics?id={smartlink_id}
Description: Retrieve detailed analytics for a specific smartlink including click counts, geographic data, device information, and time-based metrics.
Headers:
Authorization: Bearer rlk_your_api_key_hereParameters:
id(query, required): The smartlink ID to get analytics for
Success Response:
{
"success": true,
"message": "Analytics retrieved successfully",
"data": {
"smartlinkId": "clp123abc456def",
"smartlinkName": "My App",
"totalClicks": 1520,
"totalQrCodeScans": 45,
"totalFallBack": 12,
"analyticsData": [
{
"date": "2024-01-15",
"clicks": 150,
"qrScans": 5,
"fallbacks": 2,
"countries": {
"US": 100,
"UK": 30,
"CA": 20
},
"devices": {
"mobile": 120,
"desktop": 30
},
"browsers": {
"chrome": 80,
"safari": 40,
"firefox": 30
}
},
{
"date": "2024-01-14",
"clicks": 135,
"qrScans": 8,
"fallbacks": 1,
"countries": {
"US": 90,
"UK": 25,
"CA": 20
},
"devices": {
"mobile": 110,
"desktop": 25
},
"browsers": {
"chrome": 75,
"safari": 35,
"firefox": 25
}
}
]
},
"timestamp": "2024-01-15T10:30:00.000Z"
}Get Analytics Summary
Endpoint: GET /api/v1/analytics/summary
Description: Retrieve a comprehensive analytics summary for all user smartlinks including totals, recent activity, and top performers.
Headers:
Authorization: Bearer rlk_your_api_key_hereSuccess Response:
{
"success": true,
"message": "Analytics summary retrieved successfully",
"data": {
"user": {
"id": "clp789user123",
"email": "[email protected]",
"subscription": "Professional"
},
"summary": {
"totalSmartlinks": 25,
"totalClicks": 15240,
"totalQrCodeScans": 450,
"totalFallbacks": 120,
"topCountries": {
"US": 8500,
"UK": 2200,
"CA": 1800,
"DE": 1200,
"FR": 1000
},
"topDevices": {
"mobile": 12500,
"desktop": 2740
}
},
"smartlinks": [
{
"id": "clp123abc456def",
"name": "My App",
"type": "App",
"clicks": 1520,
"qrScans": 45,
"fallbacks": 12,
"relink": "https://relink.is/myapp"
},
{
"id": "clp456def789ghi",
"name": "Landing Page",
"type": "Landing",
"clicks": 890,
"qrScans": 15,
"fallbacks": 5,
"relink": "https://relink.is/mylanding"
}
],
"recentActivity": [
{
"smartlinkId": "clp123abc456def",
"smartlinkName": "My App",
"action": "click",
"timestamp": "2024-01-15T14:30:00.000Z",
"country": "US",
"device": "mobile",
"browser": "chrome"
},
{
"smartlinkId": "clp456def789ghi",
"smartlinkName": "Landing Page",
"action": "qr_scan",
"timestamp": "2024-01-15T14:25:00.000Z",
"country": "UK",
"device": "mobile",
"browser": "safari"
}
]
},
"timestamp": "2024-01-15T10:30:00.000Z"
}Analytics Data Structure
Metrics Overview
Click Metrics:
totalClicks: Total number of clicks on the smartlinktotalQrCodeScans: Total QR code scans for QR-enabled smartlinkstotalFallBack: Total fallback redirections when primary links are unavailable
Geographic Data:
- Country-based click distribution
- Regional performance insights
- Geographic trends over time
Device Analytics:
- Mobile vs Desktop usage
- Browser distribution
- Platform preferences
Temporal Data:
- Daily click patterns
- Time-based performance trends
- Activity timestamps
Response Fields
| Field | Type | Description |
|---|---|---|
smartlinkId | string | Unique identifier for the smartlink |
smartlinkName | string | Display name of the smartlink |
totalClicks | number | Total click count |
totalQrCodeScans | number | Total QR code scans |
totalFallBack | number | Total fallback redirections |
analyticsData | array | Daily analytics data points |
countries | object | Country-based click distribution |
devices | object | Device type distribution |
browsers | object | Browser distribution |
Code Examples
cURL Examples
Get Smartlink Analytics:
curl -X GET "https://relink.is/api/v1/smartlink/analytics?id=clp123abc456def" \
-H "Authorization: Bearer rlk_your_api_key_here"Get Analytics Summary:
curl -X GET https://relink.is/api/v1/analytics/summary \
-H "Authorization: Bearer rlk_your_api_key_here"JavaScript Examples
// Get specific smartlink analytics
async function getSmartlinkAnalytics(smartlinkId) {
const response = await fetch(`https://relink.is/api/v1/smartlink/analytics?id=${smartlinkId}`, {
headers: {
'Authorization': 'Bearer rlk_your_api_key_here'
}
});
const analytics = await response.json();
if (analytics.success) {
console.log('Total Clicks:', analytics.data.totalClicks);
console.log('QR Scans:', analytics.data.totalQrCodeScans);
console.log('Analytics Data:', analytics.data.analyticsData);
}
return analytics;
}
// Get analytics summary for all smartlinks
async function getAnalyticsSummary() {
const response = await fetch('https://relink.is/api/v1/analytics/summary', {
headers: {
'Authorization': 'Bearer rlk_your_api_key_here'
}
});
const summary = await response.json();
if (summary.success) {
console.log('Total Smartlinks:', summary.data.summary.totalSmartlinks);
console.log('Total Clicks:', summary.data.summary.totalClicks);
console.log('Top Performers:', summary.data.smartlinks);
}
return summary;
}Python Examples
import requests
import json
API_KEY = "rlk_your_api_key_here"
BASE_URL = "https://relink.is/api/v1"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
def get_smartlink_analytics(smartlink_id):
"""Get analytics for a specific smartlink"""
response = requests.get(
f"{BASE_URL}/smartlink/analytics",
headers=headers,
params={"id": smartlink_id}
)
return response.json()
def get_analytics_summary():
"""Get analytics summary for all smartlinks"""
response = requests.get(f"{BASE_URL}/analytics/summary", headers=headers)
return response.json()
# Usage examples
analytics = get_smartlink_analytics("clp123abc456def")
if analytics["success"]:
print(f"Total Clicks: {analytics['data']['totalClicks']}")
print(f"QR Scans: {analytics['data']['totalQrCodeScans']}")
summary = get_analytics_summary()
if summary["success"]:
print(f"Total Smartlinks: {summary['data']['summary']['totalSmartlinks']}")
print(f"Total Clicks: {summary['data']['summary']['totalClicks']}")Error Responses
Smartlink Not Found
{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Smartlink not found"
},
"timestamp": "2024-01-15T10:30:00.000Z"
}Unauthorized Access
{
"success": false,
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid API key"
},
"timestamp": "2024-01-15T10:30:00.000Z"
}Invalid Smartlink ID
{
"success": false,
"error": {
"code": "VALIDATION_FAILED",
"message": "Invalid smartlink ID format"
},
"timestamp": "2024-01-15T10:30:00.000Z"
}Best Practices
Performance Optimization
- Cache analytics data when possible to reduce API calls
- Use the summary endpoint for dashboard views
- Implement pagination for large datasets
Data Interpretation
- Monitor click patterns to identify peak usage times
- Analyze geographic data to understand your audience
- Track device preferences to optimize smartlink design
Rate Limiting
- Analytics endpoints are subject to the same rate limits as other API endpoints
- Professional: 1000 requests per hour
- Enterprise: 5000 requests per hour
Data Retention
- Analytics data is retained for 12 months
- Historical data older than 12 months may not be available
- Export important analytics data for long-term storage