How do I connect Meta Pixel?
Last checked 31 Aug 2026
Short answer
Ask Lovable to add your Meta Pixel ID as a script in the site's shared head, and fire a PageView (or custom) event on each route change since Lovable apps are single-page apps.
Setup steps
- Get your Pixel ID from Meta Events Manager.
- Ask Lovable:
"Add my Meta Pixel (ID XXXXXXXXXX) to the site, firing a PageView event on load and on every route change."
Why the route-change note matters
Lovable builds React single-page apps (or TanStack Start apps), so navigating between pages doesn't reload the document. Meta's default snippet only fires once unless you explicitly trigger a PageView on each route change — otherwise Meta will undercount pageviews and your ad campaigns will look worse than they are.
Tracking conversions, not just pageviews
For ad campaigns you'll usually want event tracking beyond PageView — Lead, Purchase, CompleteRegistration. Ask for these explicitly and tie them to the actual user action:
"Fire a Meta Pixel 'Lead' event when someone submits the contact form, and a 'Purchase' event on the payment success page with the order value."
Verifying it works
Use the Meta Pixel Helper browser extension, or Events Manager's Test Events tool, against your published or preview site.
What usually goes wrong
- Pixel only firing on the homepage because it was added to one component instead of the shared layout.
- Purchase/value events missing the actual order amount, which breaks ROAS reporting in Meta Ads.
- iOS/browser tracking prevention reducing accuracy — expect Meta's numbers to undercount compared to your own database, and treat them as directional.
- Consent requirements: if you serve EU/UK visitors, you likely need a cookie banner before the pixel fires — that's a legal/compliance decision for you to make, not something Lovable configures automatically.
If you're running paid ad campaigns and need reliable server-side conversion tracking (Meta's Conversions API) on top of the pixel, that's a more involved integration PromptSites.com can set up.
Sources
Was this answer helpful?
Related questions
- AnswerHow do I install Google Tag Manager?Ask Lovable to add your GTM container snippet to the site's shared head and body, then manage individual tags (analytics, ads, pixels) from within Tag Manager itself.
- AnswerHow do I connect an API to Lovable?Describe the API and what you want it to do in Chat; Lovable will typically wire the call through a server function (Edge Function) so any API key stays off the client.
- AnswerHow do I use webhooks?Webhooks let external services notify your Lovable app when something happens; ask Lovable to create a server function URL as the webhook endpoint, and configure that URL in the third-party service.
- AnswerHow do I connect an email marketing platform?Ask Lovable to send new subscribers or events to your email platform's API (Mailchimp, ConvertKit, Klaviyo, etc.) via a server function using an API key stored as a secret.