Everything you need,
nothing you don't
Get up and running in under a minute. Seriously. We timed it.
Quick start
Three steps. That's all it takes.
Add the snippet
Paste one line of code into your site's HTML head. Done.
Watch data flow
Visit your site once and your dashboard lights up with real-time data.
Tracking snippet
Add this script tag to your website's <head>. That's literally it.
<script
defer
data-domain="yourdomain.com"
src="https://datakool.com/tracker/script.js"
></script>Custom events
Track signups, purchases, downloads — anything you want.
The datakool() function
Call the global datakool() function anywhere on your site to track custom events.
// Track a custom event
datakool('Signup')
// Track with custom properties
datakool('Purchase', {
meta: { plan: 'pro', amount: '9.00' }
})
// Track with a callback
datakool('Download', {
callback: function() {
window.location = '/download/file.zip'
}
})Stats API
Access your data programmatically. Build anything.
/api/v1/stats/realtime/visitorsGet the number of current visitors on your site.
/api/v1/stats/aggregateGet aggregate stats (visitors, pageviews, bounce rate, etc).
/api/v1/stats/timeseriesGet time-bucketed visitor/pageview data for charts.
/api/v1/stats/breakdownGet top values for any property (page, source, country, browser, etc).
Example
Request
curl -H "Authorization: Bearer dk_your_api_key" \
"https://datakool.com/api/v1/stats/aggregate?site_id=example.com&period=30d"Response
{
"data": {
"visitors": 12453,
"pageviews": 48291,
"bounce_rate": 42.3,
"visit_duration": 154,
"views_per_visit": 3.9
}
}MCP Server
Query your analytics with Claude Code, Cursor, or any AI tool that supports the Model Context Protocol.
Setup
Connect your Datakool analytics to Claude Code with one command. You'll need an API key from your account settings (Pro or Founder plan required).
claude mcp add datakool \
--transport http https://datakool.com/mcp \
--header "Authorization: Bearer YOUR_API_KEY"Available tools
Once connected, just ask your AI assistant things like "How many visitors did example.com get this week?" or "Show me the top traffic sources for the last 30 days."
Framework guides
Copy-paste snippets for every stack.
WordPress
Add this to your theme's functions.php file:
function datakool_script() {
echo '<script defer
data-domain="yourdomain.com"
src="https://datakool.com/tracker/script.js">
</script>';
}
add_action('wp_head', 'datakool_script');Next.js
Use the Script component in your app/layout.tsx:
import Script from 'next/script'
export default function Layout({ children }) {
return (
<html>
<head>
<Script
defer
data-domain="yourdomain.com"
src="https://datakool.com/tracker/script.js"
strategy="afterInteractive"
/>
</head>
<body>{children}</body>
</html>
)
}Remix
Add via the links function in app/root.tsx:
export function links() {
return [
{
rel: 'preload',
href: 'https://datakool.com/tracker/script.js',
as: 'script',
},
]
}
// In your head:
<script
defer
data-domain="yourdomain.com"
src="https://datakool.com/tracker/script.js"
/>Astro
Add to your layout's <head> section:
---
// src/layouts/Layout.astro
---
<html>
<head>
<script
defer
data-domain="yourdomain.com"
src="https://datakool.com/tracker/script.js"
></script>
</head>
<body>
<slot />
</body>
</html>Hugo
Add to layouts/_default/baseof.html inside the head:
<!-- layouts/_default/baseof.html -->
<head>
<script
defer
data-domain="yourdomain.com"
src="https://datakool.com/tracker/script.js"
></script>
</head>Static HTML
Just drop this in your <head> tag:
<script
defer
data-domain="yourdomain.com"
src="https://datakool.com/tracker/script.js"
></script>