How to Add Google Analytics to a Lovable Project
Install GA4 correctly, verify it is firing, and track the events that actually tell you something.
Published 24 Aug 2026 · Tested with Lovable as of 24 Aug 2026

Overview
GA4 tells you which pages people visit. Custom events tell you what they do. You need both to make content decisions.
Beginner explanation: Installing analytics is the easy part. Deciding which five events matter is the useful part.
Technical explanation: Add the GA4 tag site-wide, confirm page views fire on client-side route changes, then push named custom events for the actions that matter.
Steps
- Create a GA4 property and copy the measurement ID.
- Ask for the tag to be added site-wide.
- Confirm page views fire when navigating between pages, not just on first load.
- Add custom events for your key actions.
- Verify in realtime reporting.
:::tip Single-page apps do not reload between pages. Always confirm route-change page views specifically. :::
What to check afterwards
- Realtime shows your visit
- Navigating pages produces multiple page views
- Custom events appear with the right names
Common problems
- Only the first page view firing. Route changes are not being tracked.
- Events with inconsistent names. They become unusable in reports.
- Tag added twice. Everything doubles.
Where people get stuck
If you have followed the steps and the result still is not right, the fastest path is usually to describe the exact behaviour you expected, the behaviour you got, and any error text, then ask for a fix in one focused follow-up prompt. If that loop is not converging, hand it over.