How to add analytics to a website made with AI
Once the site is online, you want to know whether anyone sees it. Analytics tells you: visits, where they came from, which pages are popular, which buttons get clicked. On a static site it is a small script on every page — a job for your AI agent.
The main options
| Cookies | What you set up | Good for | |
|---|---|---|---|
| Google Analytics 4 | Yes | A Google account and a measurement ID | Detailed reports, links with Google Ads |
| Cloudflare Web Analytics | No | A Cloudflare account and a script | Simple visitor numbers |
| Plausible, Fathom, Umami | No | An account and a script | Simple dashboards that respect privacy |
Cookies and consent
In the EU and the UK, analytics that uses cookies generally needs the visitor's consent first, which means a consent banner. Tools that work without cookies are often used without one, but the rules differ from country to country, so check what applies to you.
How to install it
- Create an account with the service and add your site's address. You get a snippet of code or an ID.
- Give it to the agent: "Add this analytics snippet to the head of every page of the site."
- Update the site, open it, and check that your visit shows up in the service's real-time view.
Say "every page". Otherwise an agent may add it to index.html only.
Measure what matters
Page views alone do not tell you whether the site works. What matters is how many people did the thing the site is for: called, wrote on WhatsApp, booked. Ask the agent to track clicks on those buttons as events — in Google Analytics they are called events, in Plausible, goals. Then you know how many visitors actually got in touch.
If you share the site in several places, add UTM tags to the links, as described in the link-in-bio guide. The analytics will show which place brings visitors.
Keep it to one tool
Every analytics script adds weight and requests. One tool is enough for a landing page; two just give you two sets of slightly different numbers.
