Table of content
Custom websites built with AI are everywhere. Web agencies deliver Lovable-built sites in a matter of days, and marketing teams create their own pages by prompt, with no CMS involved. The same question keeps coming up: can you measure a "vibe-coded" site as well as a WordPress or Shopify one? Our answer is yes, and often better. Clean code, a dataLayer written at the source and a built-in backend make an ideal foundation for top-tier server-side tracking, as long as the AI is given clear rules.
In short
Lovable generates a React application: after the first load, navigation happens without page reloads. Every page change must be sent to the dataLayer.
The A-Track architecture: consent banner and Consent Mode v2, web Google Tag Manager, then a server GTM container hosted by Stape on a subdomain of your site, which distributes to GA4, Google Ads, Meta, LinkedIn, Microsoft Ads and Brevo.
Forms go through Lovable's backend: the lead reaches Brevo through the API, with its source, and the conversion is sent server to server.
The tagging plan becomes a rule for the AI, written into the Lovable project instructions.
An AI that codes fast can also break measurement fast: daily monitoring is part of the setup.
Why an AI-built site is good ground for tracking
On a traditional CMS, measurement is often built in layers: one plugin for GA4, another for the Meta pixel, a theme injecting its own scripts, a form nobody quite knows how it sends its data. A Lovable site has none of that. The code belongs to the project, it can be versioned (GitHub sync) and it follows a precise specification.
A single entry point: Google Tag Manager is the only way in for tags. No plugin adds a script behind your back.
Events at the right moment: the code sends the event at the exact moment the action succeeds, for instance when the backend confirms the form was saved, not on a mere button click.
A built-in backend: Lovable Cloud provides a database and server functions (edge functions, built on Supabase technology). That is the basis for server-to-server measurement, independent of the browser.
Vibe coding also comes with three pitfalls of its own:
Page views: without configuration, a single-page application counts one page view per visit, or duplicates instead.
Scripts added "to be helpful": ask it to "add Google Analytics" and the AI will happily hard-code the gtag script or a Meta pixel into index.html, outside GTM and before any consent.
Silent regressions: a prompt that rebuilds a component can delete a dataLayer push without anyone noticing. The form still works, but conversions stop.
The A-Track architecture for a Lovable site
Our reference setup comes down to six building blocks. It works just as well for a corporate site as for a lead generation platform.
Consent: a CMP (CookieYes, Cookiebot, OneTrust, etc.) loads first. It passes the visitor's choice to Google through Consent Mode v2, to Microsoft through UET Consent Mode, and to the measurement server.
Web GTM: a single container, loaded from your subdomain with Stape's Custom Loader. No other measurement script in the code.
dataLayer: the React code pushes the events defined in the tagging plan (page_view, generate_lead, sign_up, phone and email clicks), each with a unique event_id.
Server GTM on Stape: hosted in a European zone, on a subdomain such as metrics.your-site.ch. It receives events, strips unnecessary data, deduplicates and distributes. See our article on GA4 server-side with Stape.
Destinations: GA4, Google Ads, Meta (Conversions API), LinkedIn (Conversions API), Microsoft Ads and Brevo.
Backend: the server function that saves a form creates the contact in Brevo through the API and sends the conversion to the measurement server, with the same event_id as the browser.
Page views: handling navigation without reloads
Older Lovable projects are React (Vite) applications rendered in the browser. Since 13 May 2026, new projects use TanStack Start with server-side rendering, which solves most indexing issues. In both cases, once the first page has loaded, navigation is still handled by the browser: no page reloads, and the Google tag does not notice the URL change on its own.
Our rule: one page view mechanism, not two.
The application router pushes a page_view event on every route change, with the URL, title, language and page type.
In GA4, automatic tracking of browser history changes (enhanced measurement) is turned off, otherwise every navigation counts twice. Google describes these options in its single-page application documentation.
In staging, we check that one navigation produces exactly one page view, including the first page after server rendering.
Forms and Brevo: the lead goes through the server
On a Lovable site, a well-built form does not write to a third party straight from the browser. It calls a server function, which saves the request and calls the Brevo API with a key stored in the project secrets, never in the visible code.
Keeping the source of every lead
On arrival, the site reads the UTMs and click IDs (gclid, gbraid, wbraid, fbclid, li_fat_id, msclkid).
With consent, they are stored first-party and attached to the form. Without consent, only the channel-level source is kept, with no personal identifier.
The server function saves them as Brevo contact attributes (source, campaign, channel): your teams know where every request came from, in Brevo and in the CRM.
Sending the conversion without losing or duplicating it
The browser pushes generate_lead to the dataLayer after the backend's positive response.
The server function sends the same event to the measurement server, with the same event_id. The ad platforms deduplicate the two signals. If a blocker stops the browser, the server signal takes over, always within the limits of consent.
On the Brevo side, Stape's Brevo tag for server GTM tracks page views and the events your automation workflows need, only if the visitor accepted marketing cookies.
Google Ads, Meta, LinkedIn, Microsoft Ads: one conversion, four platforms
The measurement server receives a conversion and passes it to each platform in its own format.
Google Ads: conversion tag served by the server, enhanced conversions for leads (hashed email address), then import of qualified leads from Brevo or the CRM. See our article on the Google Ads Data Manager.
Meta: Conversions API with event_id deduplication and the _fbp and _fbc cookies preserved. Details in our article on Meta CAPI server-side.
LinkedIn: Conversions API, especially useful in B2B to feed qualified leads back. See our article on LinkedIn CAPI.
Microsoft Ads: UET tag with its Consent Mode, msclkid kept for attribution and offline conversion imports.
GA4 and Search Console: connecting measurement and visibility
GA4: one property, one web stream, key events limited to what matters (leads, sign-ups, contacts), custom dimensions (language, page type, form) and internal traffic excluded. The AI assistant channel deserves tracking too: see our article on AI traffic in GA4.
Search Console: the domain is verified through DNS, the sitemap submitted and the property linked to GA4. Lovable now offers an SEO review and a Search Console integration in the editor. To see what Google actually receives, Search Console's URL Inspection tool remains the reference.
Search Console does not go through server-side: it measures organic visibility on Google's side. It complements the setup, it does not replace it.
Measurement subdomain and Safari: the setting that makes the difference
The measurement server answers on a subdomain of your site, created with a simple DNS record, while the site itself stays hosted by Lovable. Safari, however, caps at 7 days the cookies set by a server whose IP address does not match the site's. Two solutions:
Same origin or Own CDN: if your domain runs through a CDN you control (Cloudflare, for example), the measurement server is served by the same infrastructure as the site. This is the most robust option (Stape documentation).
Cookie Keeper: otherwise, Stape's Cookie Keeper stores and restores measurement cookies, for visitors who have consented.
On the data side, Stape hosts the container in the European Union, whose member states offer an adequate level of protection under the FADP. The server also lets you clean data before it is sent to Google. Transfers to the ad platforms still need to be documented in your privacy policy (see our FADP and GDPR guide).
Giving the AI rules: the tagging plan inside Lovable
This is the heart of our method for AI-built sites. Measurement must not depend on the memory of whoever writes the prompt: it must be a rule the AI applies on its own.
Project instructions: Lovable lets you save persistent instructions, up to 10,000 characters per project, alongside instructions shared across the whole workspace.
AGENTS.md file: at the project root, it lists the technical rules the AI rereads every session, including the measurement files never to change without approval.
Contributor access: A-Track joins the project as a contributor and reviews any change that touches measurement.
For web agencies: measurement rules go into the workspace instructions, so every new client site starts with the right naming.
Sample A-Track rules for a Lovable project
No measurement script or pixel outside Google Tag Manager.
Every form pushes generate_lead with form_id and event_id, only after the backend's positive response.
Every route change pushes a single page_view.
Never put an email address or any personal data in a URL.
When rebuilding a component, keep every existing dataLayer push.
The Content Security Policy (CSP) allows the measurement subdomain.
After launch: monitor every day
On a site built by prompt, the code changes often, and fast. Every day we monitor event volumes, the gap between leads received in Brevo and conversions counted in GA4 and Google Ads, the consent rate and the absence of tags before consent. An alert goes out as soon as a metric drops. We explain this approach in our article on monitoring server-side tracking.
Where to start
Remove from the code any measurement script added outside GTM.
Write the tagging plan and add it to the Lovable project instructions.
Route forms through a server function connected to Brevo, with the lead's source.
Deploy server GTM on Stape on your subdomain, then connect GA4, Google Ads, Meta, LinkedIn, Microsoft Ads and Brevo.
Test in Safari, then set up daily monitoring.
An AI-built site is not a compromise on data. Properly framed, it is one of the cleanest foundations for reliable, compliant server-side tracking.
Is your site built with Lovable or another AI tool?
A-Track checks your page views, forms, consent and the conversions sent to Google Ads, Meta, LinkedIn and Brevo, then tells you what to fix first.
Free flash audit within 48 hours, for businesses and web agencies alike.