Add analytics to your site with AI: the prompt pack

5 min each · vibecode · updated June 2026

Quick answer. You do not have to read analytics documentation. Paste the right prompt into Claude or ChatGPT, give it your framework and IDs, and it writes the code and tells you where it goes. Below are five battle-ready prompts: install GA4, track a custom event, generate a sitemap, add a cookie-consent banner, and audit your existing tags. Tell the AI your stack, paste the prompt, ship the output. This is the lazy, correct way to wire up a site in an afternoon.

Docs are for people with time. These five prompts get an AI to do the wiring while you stay in build mode. Give it your real stack and it writes the code, points at the file, and tells you how to check it.

What you'll need

How to use the pack

  1. Pick the job. Choose the one of the five prompts below that matches what you are doing.
  2. Fill in the brackets. Replace the bracketed bits with your framework, IDs, and any code the AI needs to see.
  3. Paste, apply, verify. Paste it into Claude or ChatGPT, apply the output, then run the verify step it gives you.

Do it with AI

The five prompts. Fill the brackets, paste, ship.

1. Install GA4 on any site
Install Google Analytics 4 on my site. Framework: [____]. Measurement ID: G-XXXXXXX. Give me the exact code, tell me which file and where, load it on every page via a shared layout, keep it async and lightweight, and tell me how to verify in Realtime.
2. Track a custom event
Add a GA4 event called [sign_up / purchase / download] that fires when [describe the moment]. Framework: [____]. Here's the relevant code: [paste]. Make it fire only on success, show me where it goes, and how to confirm in DebugView.
3. Generate a sitemap.xml
Generate a valid sitemap.xml for my site. Framework: [____]. My pages are: [list or describe how routes are generated]. Make it update automatically when I add pages, include lastmod dates, and tell me where to put it so it serves at /sitemap.xml. Then tell me how to submit it in Search Console.
4. Add a cookie-consent banner
Add a lightweight cookie-consent banner to my site that holds GA4 until the user accepts, using Google Consent Mode v2. Framework: [____]. Keep it fast, accessible, and not annoying. Show me the code and where it goes.
5. Audit my existing tags
Here's my site's head and any analytics code: [paste]. Audit it. Tell me if GA4 is installed correctly, if anything is double-firing, if tags are blocking render, and exactly what to fix. Be specific.

Always run the verify step the AI gives you. If its code does not fire, paste the error back and ask it to fix it.

How to check it worked

Each prompt output ends with its own check, usually GA4 Realtime or DebugView for tracking, or the Search Console sitemap report for the sitemap. Run that check before you trust it.

Common mistakes

FAQ

Can I really set up analytics without knowing how to code?
Yes. These prompts get Claude or ChatGPT to write the code and tell you exactly where it goes. You are pasting, not programming.
Which is better for this, Claude or ChatGPT?
Both handle these well. Give either one your real framework and IDs, and always run the verification step on the output.
Is AI-generated tracking code safe to ship?
It is standard, public Google snippet code. The risk is not safety, it is silent breakage, so always confirm the event fires in DebugView before relying on it.

You taught the AI to wire it. We read it back.

You just taught an AI to wire up your analytics.

Holy Bucket is the other half: an AI that reads the data back to you in plain English so you never open GA4 to make sense of it.

Keep going

Last updated June 2026. By Holy Bucket.