Web Analytics for AI Coders | SheCodes
Beginner 4 min read

Web Analytics for AI Coders

Know who visits your site, what they click, and where they leave. Analytics turns guesswork into real answers.

In this chapter

  • What analytics tools track and why every site needs one
  • How to read visitor numbers, bounce rate, and traffic sources
  • How to ask AI to set up Plausible, Vercel Analytics, or PostHog
  • What to actually do with the data once you start collecting it

Why Add Analytics?

Without analytics, you're building in the dark. You have no idea if anyone is visiting, what they like, or where they get stuck.

Know Your Visitors See how many people visit, where they come from, and what devices they use.
See What Works Find out which pages are popular and which buttons people actually click.
Find Drop-Offs Discover where users leave your site so you can fix the problem.
Track Growth Watch your traffic grow over time and see which marketing efforts pay off.

Analytics Platforms

Pick one to start with. You can always switch or add more later.

Setting Up Analytics

You don't need to understand the technical details. Just tell your AI tool which platform you want, and it will handle the rest.

Add Vercel Analytics

“Add Vercel Analytics to my Next.js project. Install the package and add the Analytics component to my root layout. I want to track page views and Web Vitals.”

Add Google Analytics

“Add Google Analytics (GA4) to my Next.js project. My measurement ID is G-XXXXXXXXXX. Add the tracking script to my root layout and make sure it works with client-side navigation. Don't track users until they accept cookies.”

Add PostHog

“Add PostHog analytics to my Next.js project. Set up the PostHog provider in my layout, configure it to track page views automatically, and show me how to track custom events like button clicks.”

Add Plausible

“Add Plausible Analytics to my Next.js project. Add the lightweight script tag to my root layout. My domain is mydomain.com. Make sure it tracks page views on client-side navigation.”

Key Metrics to Track

Here are the numbers that actually matter for most websites.

Unique Visitors How many different people visited your site. The most basic measure of traffic.
Page Views Total pages loaded. If one person visits 5 pages, that's 5 page views.
Bounce Rate Percentage of visitors who leave after seeing just one page. Lower is usually better.
Top Pages Which pages get the most visits. Focus your effort on improving these.
Traffic Sources Where visitors come from: Google, social media, direct links, or other sites.
Conversion Rate Percentage of visitors who do what you want them to do (sign up, buy, etc.).

Privacy & GDPR Basics

If your site has visitors from Europe (and it probably does), you need to follow some rules about tracking.

Live example
Cookie Consent BannerIf your analytics tool uses cookies (Google Analytics does), you need a banner asking visitors for permission before tracking them.
Privacy PolicyYou need a page explaining what data you collect, why, and how visitors can opt out. Link to it from your footer.
No Tracking Before ConsentDon't load analytics scripts until the visitor clicks 'Accept' on your cookie banner.
Cookie-Free AlternativesTools like Plausible and Fathom don't use cookies, so they don't need a cookie consent banner in most cases.

Prompt This

Copy-paste these prompts into your AI tool to apply what you just learned.

ADD GOOGLE ANALYTICS

“Add Google Analytics to my Next.js app. Track page views automatically and set up custom events for [button clicks / form submissions / sign-ups].”

BUILD AN ANALYTICS DASHBOARD

“Add a simple analytics dashboard to my admin panel that shows [total users, page views this week, most popular pages] using data from my database.”

Frequently Asked Questions

Which analytics tool should I use?

Vercel Analytics is the easiest if you're deployed on Vercel: zero configuration. Google Analytics is the most comprehensive and free. Plausible and Fathom are privacy-friendly alternatives that don't need cookie banners. For most projects, Vercel Analytics or Plausible is the simplest choice.

Do I need a cookie consent banner?

If you use Google Analytics or any tool that tracks users with cookies, yes. GDPR and similar laws require consent. Privacy-friendly tools like Plausible, Fathom, and Vercel Analytics don't use cookies, so they don't need consent banners.

What metrics actually matter?

For most sites: page views (how many people visit), bounce rate (how many leave immediately), and top pages (what content people care about). For apps: also track signups, feature usage, and retention. Don't track everything: focus on metrics that inform decisions.