Step-by-step guide to integrating Bolt.new AI with Google Analytics in 2025 to boost tracking accuracy, insights, and site performance.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
You don’t “integrate Bolt.new with Google Analytics” directly. Bolt.new is just the development workspace. What you actually do is: inside a Bolt.new project, you write frontend or backend code that talks to Google Analytics 4 (GA4) through its real APIs. GA4 exposes only two useful integration paths: sending events via the Measurement Protocol API, or reading analytics via the GA4 Data API. So: Bolt.new isn’t integrated — your code running inside it is.
To “integrate” GA4 from Bolt.new, you build one of these:
Both are standard HTTPS REST APIs. Bolt.new simply hosts your Node.js/React code during development.
This is the most common use case when building or testing an app in Bolt.new. You need:
Then you can send events directly from a Bolt.new backend route.
// Example: send a GA4 event from a Node.js backend route in Bolt.new
import express from "express";
import fetch from "node-fetch";
const app = express();
app.use(express.json());
app.post("/track", async (req, res) => {
const { eventName, params } = req.body;
const GA_MEASUREMENT_ID = process.env.GA_MEASUREMENT_ID; // set this in Bolt.new env
const GA_API_SECRET = process.env.GA_API_SECRET; // set this in Bolt.new env
const url = `https://www.google-analytics.com/mp/collect?measurement_id=${GA_MEASUREMENT_ID}&api_secret=${GA_API_SECRET}`;
const payload = {
client_id: "bolt-demo-user-1234", // normally a real user/device ID
events: [
{
name: eventName,
params: params
}
]
};
const result = await fetch(url, {
method: "POST",
body: JSON.stringify(payload)
});
res.json({ status: result.status });
});
export default app;
In your frontend (React running in Bolt.new), you’d call this route whenever something happens:
// Example React call
fetch("/track", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
eventName: "button_click",
params: { button_id: "signup" }
})
});
This works exactly the same when deployed outside Bolt.new.
This is for dashboards, admin tools, or automated reporting. You must use a Google Cloud Service Account because GA4 Data API requires OAuth2 service credentials.
You need:
Then you can run a GA4 Data API query like this:
// Query GA4 analytics from Bolt.new using GA4 Data API
import {BetaAnalyticsDataClient} from "@google-analytics/data";
const client = new BetaAnalyticsDataClient({
credentials: JSON.parse(process.env.GA_SERVICE_ACCOUNT_JSON) // store JSON in env
});
export async function getActiveUsers() {
const [response] = await client.runReport({
property: "properties/YOUR_GA4_PROPERTY_ID",
metrics: [{ name: "activeUsers" }],
dimensions: [{ name: "country" }]
});
return response;
}
This will return real analytics from your GA4 property.
This mirrors how your actual production app will work.
You don’t integrate “Bolt.new AI” with Google Analytics — you integrate your code (built inside Bolt.new) with GA4 through two official APIs. Sending events uses the Measurement Protocol; reading data uses the GA4 Data API with a Google service account. Both are standard HTTPS calls, and Bolt.new simply provides the development workspace to wire and test them.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.