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
- A site you can edit (any framework).
- Claude or ChatGPT open in another tab.
- Your GA4 Measurement ID (G-XXXXXXX) for the install and event prompts.
How to use the pack
- Pick the job. Choose the one of the five prompts below that matches what you are doing.
- Fill in the brackets. Replace the bracketed bits with your framework, IDs, and any code the AI needs to see.
- 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.
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.
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.
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.
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.
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
- No framework, no IDs. Pasting a prompt without your real framework and IDs makes the AI guess, and guesses break.
- Shipping without verifying. Always run the verify step. Confirm the event fires before you rely on it.
- A second GA4 tag. Letting the AI add another GA4 tag when you already have one. Use prompt 5 to catch double-fires.
- Skipping consent. If you have EU traffic, run prompt 4. Do not skip consent where you need it.
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.