Google Analytics has been on this site since the Obsidian Publish days, and it answers the aggregate questions fine: how many visitors, which pages get read, where people come from. What it doesn't answer is a question I've actually had since I first wrote down my website ideas: how does one person move through the site?
I want the path. Home, then About, then a publication, then back to the blog — or whatever the real sequence is. And I want to know which link on which page got clicked to make that happen, so I can tell which connections between pages are doing work and which are dead ends. That shapes what I write and link next.
Why Application Insights
This site is a Next.js app on Azure Static Web Apps, so the Azure-native answer is Application Insights. It's the monitoring service that already collects page views, and it lets me attach custom events to those views with a shared identifier, then query the whole thing as a time-ordered log.
The setup is three small pieces:
- An Application Insights resource in the same Azure resource group as the site. The free tier covers a personal site many times over.
- The browser SDK (
@microsoft/applicationinsights-web), initialized once in the site layout with the resource's connection string. It tracks page views automatically, including client-side navigation between pages. - A click listener that records a
LinkClickevent for every link click, with three properties: the page it was clicked from, the link's destination, and the link's text.
The visitor ID
To stitch page views and clicks into one path, every event needs a per-visitor identifier. Application Insights generates its own user and session IDs, but I wanted one stable ID I control, so the site generates a random GUID once, stores it in localStorage, and attaches it to every event as a visitorId custom property through a telemetry initializer. It's random — not derived from anything about the visitor — and it lives only in that visitor's browser.
Reading the path
With that in place, the path is a query, not a dashboard. In Log Analytics, page views for one visitor in order:
pageViews
| where timestamp > ago(30d)
| extend visitorId = tostring(customDimensions.visitorId)
| order by timestamp asc
| project timestamp, visitorId, name, url
And the clicks that connect them:
customEvents
| where name == "LinkClick"
| project timestamp,
visitorId = customDimensions.visitorId,
page = customDimensions.page,
href = customDimensions.href,
text = customDimensions.text
| order by timestamp asc
Group either query by visitorId and you get the sequence: which pages someone read, in which order, and which links carried them there. Over time that tells me which of my internal links people actually follow — the same kind of graph the site's sidebar already shows, but drawn from real behavior instead of from the links I wrote.
This isn't a new idea
This kind of analysis has a name — path analysis, or clickstream analysis — and the big analytics platforms all ship it: GA4's Path exploration, Mixpanel's Flows, and Amplitude's Pathfinder (now folded into Journeys). They usually draw it as a Sankey diagram, where the width of each stream is the volume of users. The research version is older still: "web usage mining," surveyed by Srivastava et al. in 2000 (paper), and Markov-chain models that predict the next page from the pages already visited, as in Zhu, Hong & Hughes 2002 (chapter). What I built here is the same idea at personal-site scale: my own events, my own query, my own graph — no platform in the middle.
See it live
Below this post is that graph, drawn from the last 7 days of real visits: pages sized by views, with an edge for every link click — thicker where more visitors made that jump. It refreshes every minute from Application Insights. Telemetry takes a few minutes to land after a visit, so it's near-live rather than instant.
Privacy
Nothing here identifies a person. The visitor ID is a random GUID, there is no login on the public site, and the events carry only page paths and link destinations — no IP addresses, no form input, nothing typed into the site. The messaging form on the site is separate and its contents are never sent to telemetry.