Skip to content
HostStack Docs

Site Analytics

Pageviews, visitors, referrers, campaigns, countries and custom events for every site you own — whether it runs on HostStack or somewhere else entirely. One script tag, about 2 KB, no cookies, and nothing that needs a consent banner. All of your sites appear on one page, so “how did everything do this week” is one glance rather than six logins.

Set it up

  1. Open Analytics in the dashboard and press Add site. Enter the bare hostname — example.com, not a URL.
  2. Paste the snippet into your <head> and deploy. If the domain is already attached to a service here, the site links itself to that service and also shows up on its Analytics tab.
html
<script defer src="https://hoststack.dev/t.js" data-site-key="site_your_key_here"></script>

The site key is public by design. It ships in an HTML attribute that anyone can read, exactly like a Sentry DSN — so it is write-only, scoped to one site, and rotatable from the dashboard. What actually protects the endpoint is the origin check and the hourly quota, both described below.

Custom events

The tracker exposes one global. Calls before it loads are simply lost rather than queued — analytics that can throw inside your page is worse than analytics that misses an event.

javascript
// Anything worth counting that isn't a pageview.
psAnalytics.track('signup_started', { plan: 'pro' });
psAnalytics.track('checkout_completed', { plan: 'pro', currency: 'EUR' });

// Metadata is optional: up to 32 keys, 4 KiB total, and it shows up as a
// breakdown when you click the event in the dashboard.

What gets stored

No cookies, no IP

Your visitor’s IP is used to look up a country at ingest and is never written to disk. The GeoIP database is self-hosted, so the address is not sent to a third party either.

A visitor is a day

The tracker keeps a random id in localStorage that rotates every UTC day. Someone who visits on Monday and Thursday is two visitors, and nothing links them — which is also what makes bounce rate and visit duration mean “per visit”.

Do Not Track is honoured

The tracker exits immediately when DNT is set. An individual visitor can also opt out permanently by setting ps_as_opt_out to 1 in localStorage.

Deleting a site deletes its data

Every event and every rollup row is removed with it, by foreign key, immediately — not on a schedule.

Ranges, retention and what the numbers mean

Raw events are kept for 35 days — five more than the longest filterable range, so a 30-day view is never missing its first day. Anything older is answered from a daily rollup, and that changes what one number means, so the dashboard says so rather than quietly showing you something else.

Up to 30 days

Unique visitors is a true distinct count over the whole range, and every breakdown can be filtered — click a country, a browser or a path to narrow everything else.

Longer than that

Daily visitors, summed — each day’s uniques added together, so a daily reader counts once per day. Filters and screen sizes are not available this far back.

Across several sites, visitors are always reported per site and never added into one total. The same person on two of your domains is two visitors, and reconciling them would require tracking people across domains — which is the one thing a cookieless tracker exists not to do.

Limits

  • Origin. Events are accepted from your site’s domain and its subdomains. Add more under the site’s settings if you serve the same app from a second hostname.
  • 50,000 events per site per hour. Over that, events are refused and counted — the dashboard shows how many, next to the chart they would otherwise have deflated. Nothing is dropped silently.
  • Rotating a key issues a new one immediately and keeps the old one working for 30 days, so rotating is never an outage.

Reporting without the script

The tracker is a convenience, not a requirement. Anything that can POST JSON can report — a server-rendered app, a mobile client, a worker.

bash
curl -X POST https://hoststack.dev/api/track/site_your_key_here/event \
  -H 'content-type: application/json' \
  -H 'origin: https://example.com' \
  -d '{
    "eventType": "pageview",
    "sessionId": "1c9d5c86-1a9e-4a6f-9b7d-6f6b0f3c2b41",
    "urlPath": "/pricing?utm_source=newsletter",
    "referrer": "https://news.ycombinator.com/"
  }'

From the CLI

bash
hoststack analytics sites
hoststack analytics stats example.com --range 30d
hoststack analytics stats --range 12mo        # every site, one table

Essential cookies only — for login sessions. No tracking. Details