Analytics

Every Cloudrizz app gets privacy-friendly traffic analytics out of the box — page views and visitor trends, with no cookie banner required. On top of that you can record your own business events (a signup, a purchase) and see them in the dashboard. Custom events are a paid-plan feature; basic traffic analytics is on every plan.

Traffic analytics needs zero setup — it's injected into your pages on deploy. This page is about custom events: the paid add-on that lets you track your own actions.

Track an event from your backend

Call env.ANALYTICS.track(name, props?, value?) from any api/*.js route. name is the event; props is optional JSON context; value is an optional number (revenue, a count) you can total later.

// api/checkout.js
export default {
  async fetch(request, env, ctx) {
    // …complete the order…
    await env.ANALYTICS.track("purchase", { sku: "pro-annual" }, 199);
    return Response.json({ ok: true });
  },
};

Client-side vs server-side

There are two ways to record an event — pick by who you want it attributed to:

  • window.cloudrizz.track(name, props?) — from the browser. Attributed to the visitor (their page, and referrer). Use it for front-end actions like “clicked upgrade”.
  • env.ANALYTICS.track(name, props?, value?) — from your backend. Attributed to the app itself (a server call can't see the visitor), so it's right for events only your server knows about — a completed payment, a webhook, a job result.

Where events show up

Tracked events appear in your app's dashboard under Events, alongside traffic, and can be exported to CSV. Cookie-based visitor tracking (with a managed consent banner) is available too — both custom events and cookie mode are paid features; see Limits & quotas.

API

  • env.ANALYTICS.track(name, props?, value?) — record a server-side event. name up to 80 chars; props serialized JSON; value a number. Returns a promise (fire-and-forget is fine).
  • window.cloudrizz.track(name, props?) — the browser-side equivalent, attributed to the visitor.

Notes

  • Custom events only record on production deploys of a paid app — on preview or free plans track() is a safe no-op, so your code never crashes.
  • Basic page-view analytics is always on and cookieless — no consent banner needed for it.