← All writing
Case StudyJun 24, 20268 min read

Building (and Growing) a Doctor's Website with an AI Agent

Rebuilding a medical practice site with an AI coding agent — a static Next.js stack, real technical SEO, and Search Console and Google Ads wired into a natural-language analytics loop. Plus the moment the data proved me wrong.

EP
Emmanuel Pérez P.
Full-Stack Engineer

A few months ago I set out to build a website for a medical practice — Dra. Lidia Pérez, a general-medicine doctor in Guadalupe, Costa Rica who specializes in the medical certificates (dictámenes) you need to get or renew a driver’s license. What started as a “just build a clean site” project turned into something more interesting: an end-to-end experiment in building and growing a site with an AI coding agent as my pair.

Here’s how it went, what worked, and the one moment the data made me eat my own conclusion.

Starting from a clean slate

The old site was a Hugo build that had drifted out of date. Rather than patch it, I rebuilt from scratch on a modern stack:

The design goal was “editorial, not clinical” — a calm navy-and-gold palette, a serif display font, and articles that actually answer the questions people Google at 11pm before their license expires. Under the hood it’s a reusable component system fed by a typed content layer, so every article is just data that renders through the same pre-rendered route.

A few touches I’m happy with:

Pairing with an AI agent

The whole thing was built with an AI agentic workflow — I worked alongside Claude Code the way you’d work with a fast, tireless junior engineer who’s read the docs. It scaffolded components, drafted article content, refactored when I changed my mind, and handled the tedious parts (structured data, metadata, image compression) while I reviewed every change.

The honest version of this story: AI didn’t replace the engineering judgment, it compressed the time between idea and working code. I still decided the architecture, read every diff, and rejected plenty. But the loop was dramatically tighter than typing it all myself.

SEO: the part everyone skips

For a business like this, the website is the marketing. So technical SEO wasn’t an afterthought:

Then I wired up GA4 with custom events for the two actions that actually matter: tapping the WhatsApp button and tapping the phone number.

Where it got fun: letting the AI read the analytics

Here’s the part I hadn’t done before. I connected Google Search Console, Google Analytics 4, and the Google Ads API to the AI agent through the Model Context Protocol (MCP) — basically giving the model live, queryable access to the marketing data.

Instead of clicking around dashboards, I could ask questions in plain language and get answers grounded in the real numbers. A few things fell out immediately:

The moment I was wrong

Now the lesson I keep coming back to.

Looking at the Google Ads data, I confidently concluded that the “Smart” campaign was driving junk — tons of low-engagement display traffic, an 85% bounce rate, and “conversions” that looked like noise. My recommendation: cut it.

The client pushed back:

“But Smart campaigns have direct call and message buttons — shouldn’t that generate leads?”

So I actually pulled the conversion breakdown instead of trusting my narrative. And I was wrong. The Smart campaign had generated 34 real phone-call leads in 30 days — people who tapped “call” right in the ad and never even loaded the website (which is exactly why they looked like “bad” traffic in GA4: they weren’t traffic at all, they were leads). Even better, the other campaign I’d assumed was working had generated 35 calls that were showing up as zero — because of a conversion-tracking mis-categorization. On a cost-per-call basis it was actually the cheaper of the two (~$0.62 vs. ~$1.81).

The real problem was never “bad campaign.” It was bad measurement. Fix the tracking, and the right decision becomes obvious.

The lesson isn’t subtle, but it’s worth saying plainly: an AI agent will produce a confident, plausible analysis from whatever data it’s looking at. The value isn’t in the first answer — it’s in being able to interrogate the data in seconds when a human asks “are you sure?” The combination of a skeptical client and instant queryable data caught a mistake that a tidy slide deck would have shipped.

What I’d take to the next project

The site’s live, the price hooks are shipped, the redirects are in, and the conversion tracking is getting fixed. The next chapter is the boring-but-best part: watching the numbers actually move.

EP
Emmanuel Pérez P.
Full-stack engineer in San José, CR. Writing about architecture, migrations, and shipping software that holds up.