Install
How-to Guide v0.5.1

Collection Vectors & /_q.js

Pick the exact deployment shape for each property—from zero-JS log tailing to first-party hybrid collection behind Nginx or Caddy.

Prerequisites
  • A running quarkd instance in standalone, server, or agent mode.
  • Access to your site's HTML template (for browser-verified pageviews) and/or Nginx/Caddy config (for server logs and first-party proxying).

Choose your collection vector

Vector What runs Best for
1. Log-only quarkd agent tails Nginx/Caddy logs (no JS) APIs, file hosts, docs mirrors — tracks Server requests & AI crawlers with zero frontend changes
2. JS-only (Hub) Page loads https://hub/q.js (813 bytes) Static hosts (Cloudflare Pages, GitHub Pages, Netlify) with no server log access
3. Hybrid via Hub Edge agent tails logs + browser loads hub /q.js Fast multi-server rollout without touching reverse-proxy routes
4. First-Party Agent Edge agent tails logs and serves /_q.js + /_q locally Production sites: resists ad-blockers, spools JS offline, raw IPs never leave the origin box
5. Standalone Single binary runs local tailers + local /_q.js + SQLite + Dashboard Single-VPS self-hosting (gives you Vector #4 on one box)

Wire first-party /_q.js in Nginx or Caddy

Print the exact proxy snippet from the CLI so browsers talk only to your own domain:

Nginx (from quarkd snippet nginx-proxy)
location = /_q.js {
    proxy_pass http://127.0.0.1:8090/_q.js;
    proxy_set_header Host $host;
}

location = /_q {
    proxy_pass http://127.0.0.1:8090/_q;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Real-IP $remote_addr;
}
Caddy (from quarkd snippet caddy-proxy)
handle /_q.js {
    reverse_proxy 127.0.0.1:8090
}
handle /_q {
    reverse_proxy 127.0.0.1:8090
}

Then add the 813-byte beacon tag to your HTML <head>:

HTML
<script defer src="/_q.js" data-site="mysite"></script>

Track custom conversion events

The beacon exposes window.quarkd(eventName) for button clicks, form submissions, or signups. It uses fetch(..., { keepalive: true }) so events complete even during page navigation:

JavaScript
document.getElementById('signup-btn').addEventListener('click', () => {
  window.quarkd && window.quarkd('signup');
});

Attach a matching conversion goal via [[sites.goals]] in server.toml, in /settings, or via the upsert_goal MCP tool.

Verify live installation

Run the built-in probe from the dashboard (Check q.js), over MCP (probe_sites), or via curl:

Shell
curl -fsSL -X POST https://analytics.example.com/api/v1/probe   -H "Authorization: Bearer $ADMIN_TOKEN"
Expected outputOutput
{
  "results": [
    { "site_id": "mysite", "installed": true, "matched_site": true, "mode": "first_party" }
  ]
}
Behind Cloudflare or another CDN? Add your proxy CIDR ranges to trusted_proxies in [server] so visitor hashes and GeoIP resolve the real client IP instead of the edge proxy. Loopback and Unix sockets are always trusted.