<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/roll-your-own-analytics-with-astro-vercel-edge-functions-and-neon-56wri2v8o" -->

---
title: Roll Your Own Analytics With Astro, Vercel Edge...
description: A step-by-step guide to building a custom analytics system using Astro, Vercel Edge Functions, and Neon serverless Postgres. The approach captures page views...
canonical: https://daily.dev/posts/roll-your-own-analytics-with-astro-vercel-edge-functions-and-neon-56wri2v8o
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Roll Your Own Analytics With Astro, Vercel Edge Functions and Neon | daily.dev
og:description: A step-by-step guide to building a custom analytics system using Astro, Vercel Edge Functions, and Neon serverless Postgres. The approach captures page views...
og:url: https://daily.dev/posts/roll-your-own-analytics-with-astro-vercel-edge-functions-and-neon-56wri2v8o
og:image: https://api.daily.dev/og/posts/56wri2V8o.png
og:image:alt: Roll Your Own Analytics With Astro, Vercel Edge Functions and Neon
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Roll Your Own Analytics With Astro, Vercel Edge Functions and Neon

**[Neon](https://daily.dev/sources/neontech)** · 7 min read · 0 upvotes · 0 comments

## Summary

A step-by-step guide to building a custom analytics system using Astro, Vercel Edge Functions, and Neon serverless Postgres. The approach captures page views with geolocation data (latitude, longitude, city, country) that Google Analytics GA4 no longer provides. The setup involves creating a Neon database table, writing a Vercel Edge Function that extracts geolocation from incoming requests, and a client-side Astro component using sendBeacon to fire page view events. Data can then be visualized as top countries/cities lists, SVG charts, or plotted on a 3D globe.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://neon.com/blog/roll-your-own-analytics-with-astro-vercel-edge-functions-and-neon>

---

Tags: [#postgresql](https://daily.dev/tags/postgresql), [#astro](https://daily.dev/tags/astro)

[View this post on daily.dev](https://daily.dev/posts/roll-your-own-analytics-with-astro-vercel-edge-functions-and-neon-56wri2v8o)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Roll Your Own Analytics With Astro, Vercel Edge Functions and Neon","url":"https://daily.dev/posts/roll-your-own-analytics-with-astro-vercel-edge-functions-and-neon-56wri2v8o","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/roll-your-own-analytics-with-astro-vercel-edge-functions-and-neon-56wri2v8o"},"datePublished":"2026-07-09T06:57:47.261Z","dateModified":"2026-07-09T07:01:38.915Z","description":"A step-by-step guide to building a custom analytics system using Astro, Vercel Edge Functions, and Neon serverless Postgres. The approach captures page views...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/076fdffc815ef18fbd69385460189c01?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/076fdffc815ef18fbd69385460189c01?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Neon","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Neon","logo":"https://media.daily.dev/image/upload/s--65EDghou--/f_auto/v1724339118/logos/neontech","url":"https://daily.dev/sources/neontech"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/roll-your-own-analytics-with-astro-vercel-edge-functions-and-neon-56wri2v8o","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"postgresql,astro","timeRequired":"PT7M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Neon","item":"https://daily.dev/sources/neontech"},{"@type":"ListItem","position":3,"name":"Roll Your Own Analytics With Astro, Vercel Edge Functions and Neon"}]}
```

