Vibe Coding with Replit -- May 4, 2026

How to Add Google Analytics to a Replit Site

By Arjita SethiMay 4, 20265 min read
Direct Answer

Add Google Analytics to a Replit site by creating a GA4 property in your Google Analytics account, copying the Measurement ID (starts with G-), and asking Claude to add the GA4 tracking script to all pages in your app. For an Express app, Claude adds it to the HTML template or layout file so it appears on every page automatically. Total setup time: 15 minutes.

What You Are Actually Building

The goal is to track visitor behavior on your Replit site. When this is done, you will have Google Analytics tracking active on your site showing real-time visitors, traffic sources, and page views. Non-technical builders complete this in Replit using Claude to write all the code — you describe what you want, Claude builds it, you test it and describe any fixes.

Google Analytics tracks who visits your site and what they do. Here is exactly how to add it to a Replit app in under 15 minutes.

What You Need First

You do not need to write any code. Claude handles all of it. Your job is to describe outcomes clearly and test what gets built.

How to Describe It to Claude

The most common mistake non-technical builders make is describing what they want at too high a level. "Add a database" is not specific enough. Claude needs to know: what data will be stored, what triggers the storage, who can access it, and what the data should look like when displayed back.

Start with the outcome, not the feature. Instead of "I need authentication," say "I need users to enter their email address, receive a six-digit verification code, and use that code to access a protected page at /dashboard."

Once Claude builds the first version, test it yourself. If something is wrong, describe the problem in plain language — what you expected to happen versus what actually happened. Claude fixes it. Repeat until it works correctly.

What the Working Version Looks Like

A correctly built version will have Google Analytics tracking active on your site showing real-time visitors, traffic sources, and page views. Run through the full user flow yourself before considering it done: create a test account, submit a test form, or make a test payment depending on what you built. If something breaks during your test, that is normal — paste the error message into Claude and describe what you were trying to do.

Common Mistakes and How to Fix Them

Frequently Asked Questions

How do I add Google Analytics to a Replit site?
Create a GA4 property, copy the Measurement ID (G-XXXXXXXXXX), and ask Claude to add the tracking script to all pages in your Express app. Total setup time: 15 minutes.
What is GA4?
Google Analytics 4 is the current version of Google Analytics. It tracks page views, user sessions, events, and conversion goals. It replaces the older Universal Analytics.
How do I know if Google Analytics is working?
Open your site in a browser, then check the Realtime report in Google Analytics. Your visit should appear within a minute if tracking is working correctly.
Can Google Analytics track form submissions in Replit?
Yes. Ask Claude to add event tracking to your form submission -- Claude will add GA4 event code that fires when the form is submitted successfully. You can then see form submission events in your GA4 Events report.
Is Google Analytics free?
Yes. Google Analytics 4 is free for most sites. Google Analytics 360 is a paid enterprise version. Free GA4 is appropriate for virtually all non-enterprise use cases.
Build With AI

Build and Track Your First App

The Vibe Coding track at Build with AI covers the complete build-to-analytics process.

Start Your 7-Day Free Trial