google-analytics-4listed
Install: claude install-skill ziniman/ai-instruct
# Google Analytics 4 Implementation Guide
> Applies to: Any website or web app | Updated: February 2026
A practical guide for implementing Google Analytics 4 (GA4) - covering installation, critical first-time setup, event tracking, e-commerce, consent, and advanced topics. Written for AI coding assistants: skip sections that don't apply to the user's setup.
> **Note:** Universal Analytics (UA / GA3) was fully sunset in 2024. GA4 is the only current Google Analytics product.
---
## Section 0: Before You Start
Answer these questions before writing any code. They determine which sections apply.
**Q: Are any of your visitors in Europe (EU/EEA) or the UK?**
Default: no - if yes, Consent Mode v2 setup is required (see [Consent Mode v2](#consent-mode-v2))
**Q: Do you run Google Ads (search, display, YouTube, or Shopping)?**
Default: no - if yes, ad consent signals matter for conversion tracking and which events you mark as conversions
**Q: Is your site a single-page app (React, Vue, Angular, Next.js, etc.) where the URL changes without a full page reload?**
Default: check the project for `package.json`, `next.config.*`, `vite.config.*`, `angular.json`, or `nuxt.config.*` - if found, assume SPA and apply the [Single-Page Apps](#single-page-apps) section automatically
**Q: Do you need to track purchases or sales?**
Default: no - skip [E-commerce Tracking](#e-commerce-tracking) if no
**Q: Do you already have a GA4 property, or is this a fresh start?**
Default: fres