KBAISE/ for lovable
Library
Docs

Connect your app to Google Analytics

about 10 minBuildingchecked 36h agoOfficial page
The short version

You can connect your Lovable app to Google Analytics to see how people use your app, like what pages they visit or buttons they click. This helps you understand your app's traffic and user behavior.

Anyone building an app who wants to track how users interact with it, like page views or sign-ups.

Do this, in order

  1. 1

    Go to Google Analytics and find your 'Measurement ID' for your app's web data stream, which starts with 'G-'.

    This unique ID tells Google Analytics where to send your app's usage data.

  2. 2

    In Lovable, go to 'Connectors', select 'Google Analytics', and click 'Add connection'.

    This starts the process of linking your Lovable project to Google Analytics.

  3. 3

    Give your connection a name, paste your 'Measurement ID' into the field, and choose who can use this connection in your workspace.

    The name helps you identify it, the ID links it to your Google Analytics, and sharing controls access for your team.

  4. 4

    Click 'Connect'.

    This saves your connection settings in Lovable.

  5. 5

    Open your Lovable app in a browser and navigate through a few pages.

    This generates activity that Google Analytics can track.

  6. 6

    In Google Analytics, go to 'Reports' then 'Realtime' to check if you see active users and page views from your app.

    This confirms that your connection is working and data is being sent correctly.

Paste this into your project

Connect my app to Google Analytics. I want to track page views and custom events like button clicks and sign-ups. My Google Analytics Measurement ID is G-XXXXXXXXXX.

Words decoded

Google Analytics 4 (GA4)
This is the latest version of Google's free tool that helps you understand how people use your website or app.
gtag.js
This is a piece of code provided by Google that your app uses to send information (like page views or button clicks) to Google Analytics.
Measurement ID
A unique code (like 'G-XXXXXXXXXX') that tells Google Analytics which specific report to put your app's usage data into.
Web data stream
In Google Analytics, this is a specific setup for collecting data from a website or web app, identified by its Measurement ID.
Custom events
These are specific actions you define and track in your app, beyond just visiting a page, like clicking a 'Sign Up' button or watching a video.
Conversions
These are important actions you want users to take in your app, like making a purchase or completing a sign-up form, which you track to measure success.
Client-side route changes
When you click a link in your app and the page content changes without the entire page reloading from the server, like in a single-page app.
UTM parameters
Small pieces of text added to the end of a web address (URL) that help you track where your website visitors came from, like a specific ad campaign or social media post.

Where people get stuck

  • Lovable does not check if your Measurement ID is correct when you save it, so a wrong ID will save without an error, and your app's data won't show up in Google Analytics.
  • This connection only sends data to Google Analytics; it cannot read your analytics data back into your Lovable app.
  • You cannot send events from your app's backend code using this connection, only from the part of your app that runs in a user's web browser.
  • If no data appears in Google Analytics, double-check that the Measurement ID in Lovable exactly matches the one in Google Analytics, and ensure no ad or tracking blockers are active in your browser.

The short version, steps, decoder and prompt on this page are written automatically from Lovable's own documentation and can lag or misread it. The official page is always the authority.