title: "How We Built a Unified Analytics Dashboard in One Day (GA4 + Cloudflare D1)" description: "Combining Google Analytics 4, Cloudflare D1, and CRM data into one real-time dashboard using Cloudflare Workers and manual JWT auth." published: 2025-12-27 author: "Alexey Anshakov"

TL;DR

  • Problem: Metrics scattered across GA4, Cloudflare D1, Workflow Engine, and CRM.
  • Solution: A unified dashboard aggregating all sources via a single API call.
  • Tech Stack: Cloudflare Workers (Hono), Manual JWT for GA4 (no SDK), ApexCharts.
  • Result: Real-time visibility, zero cold starts, built in < 8 hours.

The Problem: Data Fragmentation

If you run a modern SaaS, your data is likely everywhere:

  • Traffic: Google Analytics 4 (Google Cloud)
  • Users: Cloudflare D1 (Edge SQL)
  • Workflows: Internal Process Engine
  • Sales: CRM (Sonar)

Checking metrics meant opening 4 tabs and mentally combining numbers. We needed a single source of truth.

The Solution: One API to Rule Them All

We built a unified Analytics Dashboard that pulls from all sources via one API call.

The Architecture

  1. Backend: Hono running on Cloudflare Workers.
  2. Auth: JWT-signed service account authenticating directly with Google APIs.
  3. Database: Cloudflare D1 for user/workflow stats.
  4. Frontend: SvelteKit + ApexCharts.

The Challenge: GA4 on the Edge

The biggest hurdle was connecting to Google Analytics 4 from Cloudflare Workers. The official Node.js SDK doesn't work in the Workers runtime (it relies on Node-specific modules).

We had to implement JWT signing manually.

How to Call GA4 API without an SDK

  1. Service Account: Create a Google Cloud Service Account with GA4 read permissions.
  2. Keys: Download the JSON key file (private_key and client_email).
  3. Crypto: Use the Web Crypto API to sign the JWT.

The Flow:

  1. Construct JWT Header (RS256) and Payload (iss, aud, exp).
  2. Sign the data using crypto.subtle.sign (RSASSA-PKCS1-v1_5).
  3. Exchange the signed JWT for an access token via https://oauth2.googleapis.com/token.
  4. Call the GA4 Data API with the access token.

It took a few hours to get the crypto right, but the result is bulletproof and runs with sub-100ms latency globally.

Why Monorepo Matters

We built this in one day.

How? Because we're running a monorepo with shared types and infrastructure.

  • Shared Auth: No need to rewrite login logic.
  • Shared UI: Reused components from our design system.
  • Shared Types: Backend API types are instantly available in the frontend.

Conclusion

You don't need expensive BI tools like Tableau or Looker for a startup dashboard. With Cloudflare Workers and a bit of crypto knowledge, you can build a custom, real-time analytics hub that fits your exact needs for $0/month (on the free tier).