Documentation

Everything you need to install and use KB365Service.

1. Add your site

Open the Dashboard, enter your admin key, click + Add Site, enter your site name and domain. You'll get a Site ID.

2. Install the tracker

Paste this inside your <head> tag — replace YOUR_SITE_ID with the ID from step 1:

<script src="https://kb365service.com/tracker.js?id=YOUR_SITE_ID"></script>

The script is under 1KB, loads async, collects no cookies, and requires no GDPR consent banner.

3. What gets collected

Field Source Notes
Page URLbrowserFull URL of the viewed page
ReferrerbrowserWhere the visitor came from
Session IDsessionStorageRandom ID, cleared when browser tab closes. No cookies.
Device typescreen.widthdesktop / tablet / mobile
CountryCloudflare headerCF-IPCountry — no IP stored
Screen sizescreen.width/heightAggregate display stats only

We do not store IP addresses, fingerprints, cookies, or any personally identifiable information.

4. API reference

POST /collect

Track a pageview. Open to all origins. Body: {"site_id","url","referrer","session_id","device","screen_w","screen_h"}

GET /api/stats/:siteId/pageviews?days=30

Daily pageview + visitor counts. Max 90 days.

GET /api/stats/:siteId/realtime

Active sessions in the last 5 minutes.

GET /api/stats/:siteId/pages|sources|countries|devices

Top pages, traffic sources, countries, device split.

GET /api/snippet/:siteId

Returns the ready-to-paste HTML snippet for a site.

GET /api/stats/compare Admin key required

All sites side-by-side. Header: X-Admin-Key: your-key

5. Self-host

git clone https://github.com/kb-software-llc/kb365service
cd kb365service/worker
npm install
npx wrangler d1 create kb365service
npx wrangler d1 execute kb365service --file=schema.sql
npx wrangler secret put ADMIN_KEY
npx wrangler deploy

cd ..
npx wrangler pages deploy public --project-name=kb365service