Hasty Briefsbeta

Bilingual

Show HN: Building My Own Google Analytics for $0

3 months ago
  • #Tracking
  • #Google Analytics
  • #Web Development
  • Building a custom Google Analytics alternative for $0.
  • Understanding the basic architecture: User's Browser → Tracking Script → Backend API → Database → Dashboard.
  • Reverse engineering Google Analytics reveals it sends collect requests on almost every event.
  • Problem 1: CORS preflight requests doubling the number of HTTP calls. Solution: Use query parameters instead of JSON body.
  • Problem 2: Bots skewing analytics data. Solution: Two-layer bot detection (client-side and server-side) with Cloudflare Worker for edge filtering.
  • Problem 3: Session management. Solution: Client-side session tracking using sessionStorage.
  • Problem 4: Tracking route changes in SPAs. Solution: Intercepting History API calls.
  • Final architecture includes Cloudflare CDN for the tracking script, Cloudflare Worker for bot detection, Backend API, MongoDB Atlas, and a Dashboard.