Hiveku already includes privacy-friendly visitor analytics — see Track Site Analytics. Use Google Analytics when you need GA-specific integrations (Google Ads conversions, advanced audiences, BigQuery export) or when your team is already on GA.
Get Your Measurement ID
Before installing, grab your GA4 Measurement ID from analytics.google.com:- Admin > Property > Data streams
- Click your web stream
- Copy the Measurement ID — it looks like
G-XXXXXXXXXX
Three Ways to Install
- AI Chat (Easiest)
- Manual Snippet
- Next.js (@next/third-parties)
Ask the AI in your project:The AI picks the right file for your stack (Next.js root layout, static site
<head>, etc.), adds the snippet, and deploys when you confirm.Using an Env Var
Whichever path you choose, it’s a good idea to read the Measurement ID from an environment variable rather than hardcoding it. This way, production uses one GA property and staging uses another (or none):Cookie Consent & Privacy
GA4 uses cookies to track users across sessions. Depending on your visitors’ location, you may need a consent banner before loading GA:- EU (GDPR) — explicit opt-in required
- California (CCPA) — opt-out required, at minimum
- Other regions — varies, check local law
Google Tag Manager
If you prefer Tag Manager, the install flow is identical — swap thegtag.js snippet for your GTM container snippet:
Verify It’s Working
Visit your site in a new tab
Load any page. Within ~30 seconds, you should see your session appear in the Realtime report.
Troubleshooting
No data showing after 24 hours
No data showing after 24 hours
Check three things: (1) Measurement ID format is
G- followed by 10 characters — older UA-prefixed IDs are discontinued; (2) the gtag/js script loads successfully in DevTools Network — if it 404s, the ID is wrong; (3) the snippet is in the rendered HTML, not just the source — a client-rendered React app may need special placement.Works in dev but not production
Works in dev but not production
Check your env var —
NEXT_PUBLIC_GA_ID has to be set in the production environment, not just locally. Vars without the NEXT_PUBLIC_ prefix aren’t exposed to the browser.Ad blockers blocking tracking
Ad blockers blocking tracking
Expected for a non-trivial slice of users. Mitigations include server-side Measurement Protocol for important events (conversions) and using Google Tag Manager’s server-side container. Don’t try to defeat ad blockers for general pageviews — you’ll erode user trust.
Duplicate events in reports
Duplicate events in reports
The GA snippet was added twice — commonly in both the root layout and a page template. Search your codebase for
G- and remove duplicates.Realtime works but reports are empty after hours
Realtime works but reports are empty after hours
GA4 processes data in batches — full reports can lag 24–48 hours after first install. Realtime is the best quick-check for “is it working.”
What’s Next?
Track Site Analytics
Use Hiveku’s built-in privacy-friendly analytics
Environment Variables
Store your Measurement ID per environment