Documentation
api.shortid.meCapture API - send events from your site (pageviews, clicks, custom events)stats.shortid.meStats API - get analytics data (visitors, pages, sources, devices)Event Tracking
Setup
1. Add your domain in Dashboard → Settings
2. Copy your API Key from project settings
3. Add script before </head>:
<script>
!function(t,e){if(!e.cr){var n=t.createElement("script");
n.src="https://cdn.shortid.me/cr.js";n.async=1;
t.head.appendChild(n);e.cr=function(){
(e.cr.q=e.cr.q||[]).push(arguments)}}}(document,window);
cr('init', 'your-domain.com');
</script>Custom Events
Track any action with optional properties:
// Simple event
cr('event', 'signup');
// With properties
cr('event', 'purchase', {
product_id: '12345',
price: 99.99,
currency: 'USD'
});
// Button click
document.querySelector('.btn').onclick = () => {
cr('event', 'cta_click', { location: 'hero' });
};Autocapture
Tracked automatically:
- Pageviews
- Clicks (buttons, links)
- Form submissions
- SPA navigation
Exclude elements:
<button data-cr-ignore>Not tracked</button>
HTTP API
POSThttps://api.shortid.me/api/event
{
"d": "your-domain.com", // domain (required)
"b": [{ // batch of events
"n": "purchase", // event name
"u": "https://...", // page URL
"ts": 1700000000000, // timestamp (ms)
"p": { // properties
"product": "pro",
"price": 99
}
}]
}Stats API
Parameters
All endpoints accept:
domainYour domain (required)periodtoday | 7d | 30d | 90dlimitResults count (default: 10)Overview
GET/api/stats/overview?domain=example.com
{"pageviews": 316, "unique_visitors": 16, "events": 667}Top Pages
GET/api/stats/pages?domain=example.com
[{"name": "/", "count": 55}, {"name": "/dashboard/", "count": 76}]Traffic Sources
GET/api/stats/sources?domain=example.com
[{"name": "Direct", "count": 128}, {"name": "google.com", "count": 45}]Devices
GET/api/stats/devices?domain=example.com
{"browsers": [{"name": "Chrome", "count": 659}], "devices": [{"name": "desktop", "count": 663}]}Geography
GET/api/stats/geo?domain=example.com
[{"name": "US", "count": 120}, {"name": "DE", "count": 45}]Timeline
GET/api/stats/pageviews?domain=example.com
[{"time": "2024-01-15T10:00:00Z", "count": 25}]Event Breakdown
GET/api/stats/event-breakdown?domain=example.com
[{"name": "pageview", "count": 316}, {"name": "click", "count": 284}]Funnel
GET/api/stats/funnel?domain=example.com&steps=/,/signup/,/dashboard/
[{"step": "/", "visitors": 100}, {"step": "/signup/", "visitors": 45}]SQL QueryAdvanced
POST/api/query
SELECT only. Max 10,000 rows, 30s timeout.
POST /api/query
Content-Type: application/json
{
"sql": "SELECT pathname, COUNT(*) as views FROM events GROUP BY pathname",
"domain": "example.com"
}