Skip to content
Datakool
Documentation

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.

1

Create an account

Sign up and add your website domain. Takes about 10 seconds.

2

Add the snippet

Paste one line of code into your site's HTML head. Done.

3

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>
Under 1KB
Async loading
No cookies

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.

GET
/api/v1/stats/realtime/visitors

Get the number of current visitors on your site.

Parameters:site_id
GET
/api/v1/stats/aggregate

Get aggregate stats (visitors, pageviews, bounce rate, etc).

Parameters:site_id, period (today, 7d, 30d, month, 6mo, 12mo)
GET
/api/v1/stats/timeseries

Get time-bucketed visitor/pageview data for charts.

Parameters:site_id, period, interval (hour, day, week, month)
GET
/api/v1/stats/breakdown

Get top values for any property (page, source, country, browser, etc).

Parameters:site_id, period, property, limit, page

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
  }
}
AI Integration

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

list_sites
List all your websites
get_realtime_visitors
Current live visitor count
get_stats
Aggregate stats with period comparison
get_timeseries
Time-bucketed trend data
get_breakdown
Top pages, sources, countries, devices...
get_goal_conversions
Goal conversion data and revenue
get_funnel
Funnel step-by-step progression

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>

Ready to get started?

Create your free account and start tracking in under a minute.

Start free trial