Guide

How to add analytics to a website built with Lovable

You built the site by describing it in a chat, so add analytics the same way. Paste one prompt into your project's Lovable chat, publish, and Lomen starts counting your visitors. No code to edit yourself.

Step by step

From sign-up to your first visitor

You never open the code. Lovable makes the change, the same way it built the site.

  1. Sign up for Lomen

    Create an account. Lomen is free during the beta, with no credit card.

  2. Add your published address

    In the dashboard, click "Add your site" and enter the address your Lovable site is published at: your own domain if you connected one, otherwise the one ending in lovable.app. Not the preview link from the editor.

  3. Copy the prompt

    Under the snippet, the dialog asks if an AI tool built your site. Click "Copy a prompt instead" and the prompt below is copied with your site id already in it.

  4. Paste it into Lovable and publish

    Paste the prompt into your project's chat and let Lovable make the change. Then click Publish in Lovable: the script only reaches your visitors once the published site has it.

  5. Open your site and see yourself live

    Open your published site in a new tab. The snippet dialog says your website is connected as soon as the first pageview arrives, and the Live tab shows you on the page you opened.

The prompt

Paste this into your Lovable chat

In your Lomen dashboard the same prompt comes with your site id filled in.

Prompt for Lovable
Add Lomen Analytics to this website.Put this script tag in the <head> of every page, exactly as written:<script defer data-site-id="your-site-id" src="https://lomenanalytics.com/api/public/track.js"></script>- If the project has an index.html, add it inside the <head> there. If the head is built in code instead, for example in a root layout or root route, add it there so every page gets it.- Add it once, as a plain script tag. Don't load it from a React effect or a component, and don't change or remove any of its attributes.- Don't change anything else in the project.

Copying it from here instead? Replace your-site-id with the id from your snippet.

FAQ

Common questions

Lomen only counts pageviews from the address you added and its subdomains, so a copy of your snippet on someone else's site cannot add to your numbers. The preview inside the Lovable editor runs on a different address, so it is left out too. Open your published site to see yourself come in.

The one people visit. That is your own domain if you have connected one to your Lovable project, or the address ending in lovable.app that Lovable published your site to.

It asks Lovable to add one script tag to the head of your pages and to change nothing else. Nothing goes live until you publish.

Yes. Sites built with Lovable usually switch pages without a full reload, and the script counts each of those page changes as a pageview, so there is nothing to add per page.

Yes. The prompt carries the same one-line script tag the docs describe. If you edit the code yourself, put it in the head of index.html, or wherever your project builds the page head.

No. It sets no cookies and never stores IP addresses. By default it saves nothing in your visitors' browsers at all.

Nothing during the beta, with no credit card. Paid plans come later, with planned pricing based on traffic from $8 a month.

See who visits what you built

One prompt, one publish. Free during the beta, no credit card.