Blog / Technical Guides

Add Google Analytics 4 to a Lovable Site (and Check It's Actually Recording)

By Keyona Meeks, Founder, ReRev Labs · Oct 31, 2026 · 8 min read

The short answer: Adding Google Analytics 4 means putting Google's tag on every page of your site with your own measurement ID. The harder part is knowing it keeps working. A tag can stop recording after a site change and nothing warns you. So check three ways: that the tag loads in the page, that Google's own reports show your visit, and once a week that yesterday's number is not zero or far below normal. I could not read Google's Analytics help pages in this session, so I give no Analytics menu paths. I describe how our own site loads the tag and give a tested weekly check. We sell build work, so weigh this with that in mind.

By the end of this post, you'll be able to:

  • Know what you need before adding the tag.
  • See how a consent-aware tag loads.
  • Check that the tag is on the page and sending.
  • Run a weekly check that catches a silent stop.

I sell build work. This post covers a site built in Lovable, but I did not read Lovable's documentation either, so I do not describe its settings. Ask Lovable, or whoever edits your site's code, where the tag should go.

What did I not confirm?

I tried to read Google's help pages for adding the tag, for the Realtime report and for DebugView. The tool I use to read pages declined all three addresses, and I did not look for another way in. So I do not quote Google on where the tag goes, what the Realtime report shows, or how to turn on debug mode. Look up current steps on Google's own pages. The checks below that do not depend on those pages are the ones I can stand behind.

What do you need first?

  • A Google Analytics account and a GA4 property.
  • The measurement ID for your site's data stream. It starts with G-. Where it sits in the Analytics screen is something I could not confirm.
  • A way to edit your site's code or its head tags.
  • A decision on consent. If you have visitors where consent rules apply, ask your attorney what you need. I am not one, and I give no rule here.

How does our own site load the tag?

Our site, rerev.io, loads Google's tag only after the visitor accepts. The code lives in index.html in our repo. In outline:

  1. The page sets up window.dataLayer and a gtag function.
  2. It sets consent to denied by default.
  3. When the visitor accepts, it adds a script that points to https://www.googletagmanager.com/gtag/js?id= plus our measurement ID.
  4. Then it calls gtag('js', new Date()) and gtag('config', ...) with the ID.

That is one working pattern, taken from our own code. It is not the only one, and I am not saying it is what Google tells you to use. Check Google's current instructions for the snippet. Never paste a measurement ID from this post. Use your own.

How do you check the tag is on the page?

Three checks that do not need the Analytics screens:

  1. View source. Open the page's source, not the inspector, and search for your measurement ID. If you use a consent banner, the tag may only appear after you accept, so accept first.
  2. Network requests. Open your browser's developer tools, go to the network tab, reload, and look for a request to googletagmanager.com that includes your ID. Our code loads the script from that address, so a request to it is what I expect.
  3. The data layer. In the developer console type window.dataLayer. In a setup like ours it holds entries once the tag is set up. An empty or undefined result means the setup code did not run.

I did not run these checks against a live property during this run. I did not want to add test visits to our analytics. The expected results come from reading our code.

How do you check Google is receiving it?

Open your own site in a fresh browser window, accept any consent banner, click around, then look in the Analytics reports for a visit. Google has a real-time view and a debug view for this purpose. I could not read either page, so I will not tell you where they are or how long they take. Look them up, and expect a short delay.

If you see nothing, go back to the three checks above. The most common reasons I can name from how the tag works are a wrong measurement ID, a consent banner that is blocking it, an ad blocker in your own browser, or the code not being on every page. I have no statistics on which is most common.

How do you catch a tag that silently stopped?

This is the check most sites lack. A site update, a new consent tool or a changed head template can remove the tag, and nothing tells you. Your report just goes flat.

Once a week, copy the last eight days of daily sessions from your report into a sheet, newest first, in column B. In C2 enter:

=IF(B2="","No data",IF(B2=0,"CHECK",IF(B2<0.3*AVERAGE(B3:B9),"CHECK","OK")))

It says CHECK when yesterday had zero sessions, or fewer than 30 percent of the average of the seven days before. The 30 percent is my starting number. For a site with few visits, a quiet day is normal, so widen it or look at weekly totals instead.

I tested this formula in LibreOffice with four made-up cases: a zero day, a normal day, a sharp drop and an empty cell. It returned CHECK, OK, CHECK and No data, as I expected. I did not test it in Google Sheets, and I did not test it on real analytics data.

If it says CHECK, run the three tag checks first. Then ask what changed on the site that week.

What about Search Console, sitemaps and titles?

Analytics tells you what visitors did. It does not tell you how you appear in search. For the crawler side, see making your Lovable website AI-crawler friendly.

Where does an LLM fit in this?

An LLM can help with the messy part: reading your page's head code and pointing out where a tag might be missing, or turning a weekly report into a plain-language note. A person should check what it says against the page, because an LLM can describe a tag that is not there. The weekly check is a plain rule that does the same thing every time. My stance: AI writes the code, plain automation runs it, and an LLM shows up only where the input is messy and a person checks the result.

Where this has limits

  • I could not read Google's Analytics help pages or Lovable's documentation. I give no menu paths and no Google quotes.
  • The loader description comes from our own code. It is one pattern. Check Google's current snippet.
  • The tag checks were not run against a live property.
  • The weekly formula was tested in LibreOffice with made-up numbers. Not in Google Sheets and not on real data.
  • The 30 percent is my starting number.
  • Consent rules vary. Ask your attorney.
  • We sell build work. Read this with that in mind.
  • No ReRev prices and no promises about results.

If you want help with this on your site, or want to claim a free rebuild of a tool you pay for, tell us what you use. Do not send passwords or login details.

Frequently asked questions

How do I add Google Analytics 4 to a Lovable site?

Put Google's tag, with your own measurement ID, on every page. Check Google's current instructions for the snippet. Ask Lovable or your developer where it belongs.

How do I know it is recording?

Check that the tag is in the page and sends a request, then look for your own visit in the Analytics reports.

What if I see no data?

Check the measurement ID, any consent banner, any ad blocker, and whether the code is on every page.

How do I catch a tag that stopped?

Compare yesterday's sessions with the average of the previous week once a week. A zero or a sharp drop is a flag.

That depends on where your visitors are. Ask your attorney.

Does this work in Google Sheets?

I tested the formula in LibreOffice. Check it with a few rows in Sheets.

Read next: Connect a Lovable site to Search Console for the search-side view, and is a Lovable website good for SEO for what the two tools taught us.