Appearance
Quickstart
Add privacy-first analytics to your website in under a minute. This guide walks you through creating a site, installing the tracker script, and viewing your first data.
Prerequisites
- A Krafter account (invite-only -- request access at app.krafter.dev)
- A website or web application where you can add a script tag
Step 1: Create a Site
You can create a site through the Krafter dashboard or via the API.
Dashboard:
- Log in to the Krafter dashboard.
- Navigate to Analytics and click Add Site.
- Enter your domain (e.g.,
example.com) and a display name. - Copy the generated site key. It starts with
sk_.
API:
bash
curl -X POST https://app.krafter.dev/api/v1/analytics/sites \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"domain": "example.com",
"name": "My Website"
}'json
{
"data": {
"id": "550e8400-e29b-41d4-a716-446655440000",
"domain": "example.com",
"name": "My Website",
"site_key": "sk_abc123def456",
"public_stats": false,
"created_at": "2025-01-15T10:00:00Z"
}
}Step 2: Add the Tracker Script
Add the following script tag to the <head> of your website, replacing sk_YOUR_SITE_KEY with your actual site key:
html
<script defer data-site="sk_YOUR_SITE_KEY" src="https://app.krafter.dev/a.js"></script>TIP
The defer attribute ensures the script loads without blocking page rendering. The tracker is under 1 KB and has zero impact on page load performance.
html
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<script defer data-site="sk_abc123def456" src="https://app.krafter.dev/a.js"></script>
</head>
<body>
<!-- Your content -->
</body>
</html>jsx
// app/layout.tsx
import Script from 'next/script'
export default function RootLayout({ children }) {
return (
<html>
<head>
<Script
defer
data-site="sk_abc123def456"
src="https://app.krafter.dev/a.js"
strategy="afterInteractive"
/>
</head>
<body>{children}</body>
</html>
)
}html
---
// src/layouts/Layout.astro
---
<html>
<head>
<script defer data-site="sk_abc123def456" src="https://app.krafter.dev/a.js"></script>
</head>
<body>
<slot />
</body>
</html>That is all you need. Page views are tracked automatically, including SPA navigation via pushState and replaceState.
Step 3: View Your Data
Open the analytics dashboard for your site:
https://app.krafter.dev/analytics/sk_YOUR_SITE_KEYYou will see real-time visitor counts, page views, top pages, referrers, countries, devices, and more.
Privacy by Default
Krafter Analytics is designed to be privacy-friendly out of the box:
- No cookies -- no consent banner needed
- No fingerprinting -- visitor identification uses a daily-rotating salted hash
- Respects Do Not Track -- if a visitor has
navigator.doNotTrackenabled, no data is collected - GDPR compliant -- no personal data is stored
INFO
Because no cookies or persistent identifiers are used, you do not need a cookie consent banner for Krafter Analytics.
Next Steps
- Track custom events and goals -- measure conversions and user actions
- Learn about privacy design -- understand how visitor privacy is protected
- Tracker reference -- full JavaScript API for
window.ka - Sites API -- manage sites programmatically
- Stats API -- query analytics data via REST