Setup guides

How to add an affiliate program to your Lovable app

Create a program on Anderro, paste one prompt into Lovable's chat to add the tracking snippet, keep your secret key in Lovable's Secrets, and pass the visitor ID to Stripe at checkout. Affiliates then get credit for every sign-up and sale they send.

Lovable steps last checked December 4, 2026.

Start your program Pricing

Lovable at a glance

Snippetsrc/routes/__root.tsx (new apps) or index.html (older apps), or let Lovable's chat add it
Secret keyMore › Settings › Secrets
PaymentsYour own Stripe account (Checkout or Payment Links)
Plan neededAny plan with the chat; editing code by hand needs a paid plan

Set up in 5 steps

1. Create your program on Anderro

Sign up, add your product and choose what affiliates earn. Anderro then shows your tracking snippet with your public key filled in. It also gives you a secret key for your server.

The public key is safe in browser code. The secret key is not: keep it in your platform's secrets as ANDERRO_SECRET_KEY, never in the page or the chat.

2. Add the snippet

Easiest: Anderro writes a prompt for your app. Paste it into Lovable's chat and Lovable adds the snippet for you.

By hand: Lovable apps made since May 2026 use TanStack Start. Put the tag in src/routes/__root.tsx, inside <head> next to <HeadContent />. Older Lovable apps (React and Vite) take it in index.html, just before </head>.

By default the snippet waits for the visitor's consent before it sets its cookie. Call window.anderro.optIn() when they accept cookies. Your setup screen in Anderro tells you if your program is set to track without waiting.

<script src="https://track.anderro.com/a.js" data-key="YOUR_PUBLIC_KEY"></script>

3. Add your secret key and record sign-ups

In Lovable, open More, then Settings, then Secrets, and add ANDERRO_SECRET_KEY. If Lovable asks for it with a secure form in the chat, use that form, never the chat box. Never put it in a VITE_ variable: those are public.

Simplest: call anderro.track in the browser right after sign-up. Most reliable: a server function (or a Supabase Edge Function in older apps) sends the sign-up with your secret key.

// right after the account is created
window.anderro?.track("signup", { email });

// on your server, after the account is created
await fetch("https://track.anderro.com/events", {
  method: "POST",
  headers: {
    "content-type": "application/json",
    "x-api-key": process.env.ANDERRO_SECRET_KEY,
  },
  body: JSON.stringify({
    type: "signup",
    customerEmail: email,
    visitorId, // sent up by the browser from window.anderro?.getVisitorId()
  }),
});

4. Connect Stripe and pass the visitor ID

In Anderro, open your product, choose Integrations, then Stripe, and copy your webhook URL. In Stripe, open Developers, then Webhooks, add an endpoint with that URL, select the seven events Anderro lists, and paste the endpoint's signing secret back into Anderro. Anderro keeps no access to your Stripe account.

Stripe Checkout: set the visitor ID on the Checkout Session in the server function (or Edge Function) that creates it. Ask Lovable to do it with the code below as a guide.

Stripe Payment Links: add the visitor ID to the link as client_reference_id.

// where your server creates the Stripe Checkout Session
const session = await stripe.checkout.sessions.create({
  // ...your existing options
  ...(visitorId && {
    client_reference_id: visitorId,
    metadata: { anderro_vid: visitorId },
  }),
});

// Stripe Payment Link: add the visitor id before sending the buyer on
const url = new URL("https://buy.stripe.com/your-link");
const vid = window.anderro?.getVisitorId();
if (vid) url.searchParams.set("client_reference_id", vid);
window.location.href = url.toString();

5. Publish and test

Click Publish again. Changes are not live until you do.

Then open your site through your own test referral link from Anderro, sign up and buy. The click, the sign-up and the sale show on your Anderro dashboard. Stripe's test mode works too: test payments never earn a commission.

The prompt to paste into Lovable

Paste this into Lovable's AI chat. When you copy it from your setup screen in Anderro, your public key is already filled in. It tells the AI where every piece goes and never to handle your secret key.

# Task: add Anderro affiliate tracking to this app

Make the changes below, then list the files you changed.

## 1. Snippet: every page, inside <head>
<script src="https://track.anderro.com/a.js" data-key="YOUR_PUBLIC_KEY"></script>
- Replace YOUR_PUBLIC_KEY with my public key. It is safe in browser code.
- After the visitor accepts cookies, call window.anderro?.optIn().

## 2. Sign-ups: server side, on every sign-up path
- In the browser, read window.anderro?.getVisitorId() and send it with the sign-up request.
- After the account is created, call:
    POST https://track.anderro.com/events
    x-api-key: <value of the ANDERRO_SECRET_KEY environment variable>
    {"type":"signup","customerEmail":"<email>","visitorId":"<visitor id>"}

## 3. Stripe checkout
- Where the server creates the Stripe Checkout Session, set client_reference_id and
  metadata.anderro_vid to the visitor id the browser sent. Do not add other payment code:
  Stripe reports payments to Anderro itself.

## 4. Secret key: I add it myself, you never see it
- Read it only on the server, only from the environment variable ANDERRO_SECRET_KEY.
- Do not ask me to paste the key into this chat. Do not print, log or write it to any file.
- If the variable is not set, stop and tell me to add it in this platform's secrets.
- Never use it in browser code.

How a sale is tied to an affiliate

The snippet remembers which affiliate sent a visitor and gives that visitor an ID. Your checkout passes the ID to Stripe, Stripe sends the sale to Anderro, and the affiliate who sent the customer is credited. Renewals need no extra code: they are matched to the customer from their first payment.

A customer who already bought through one affiliate stays with that affiliate, and an affiliate buying through their own link earns nothing unless you allow it.

What to know on Lovable

  • Lovable's preview and your published app share one database, so test sign-ups made in the preview land in your real data.
  • Sales taken through Lovable's built-in payments are not visible to Anderro yet. Connect your own Stripe account to pay commissions on them.
  • Your app on name.lovable.app works; Anderro asks once whether that address is your real site or a preview.
  • US dollars only. A payment in another currency is not recorded, and Anderro's Integrations page tells you when one arrives.
  • Commissions wait out a hold you choose (7 to 90 days), so a refund inside the hold never costs you a commission.

If something does not show up

Test sign-ups appear in my real data

Lovable's preview and your published app share one database. Test on the published app, and delete test accounts afterwards.

Sales made with Lovable's built-in payments are missing

Anderro cannot see those yet. Connect your own Stripe account to pay commissions on them.

Nothing changed on my live app

Click Publish again. Code and secret changes reach the live app only when you do.

My test click does not show up

The snippet waits for consent: accept cookies on your site, and check that your cookie banner calls window.anderro.optIn(). If your site sets a Content Security Policy, allow https://track.anderro.com in script-src and connect-src.

A sale shows up, but no affiliate is credited

The visitor ID did not reach the checkout. Open the payment in your billing dashboard and check it carries the ID, and buy in the same browser you opened the referral link in.

Questions

Does Lovable have its own affiliate program?

Yes. Lovable runs an affiliate program, applied for through Impact, that pays up to $100 for each first-time subscriber you refer. That pays you for promoting Lovable. This guide is the other way round: running an affiliate program for an app you built. Looking for more software to promote? Browse SaaS affiliate programs on Anderro.

Can Lovable add the whole setup for me?

Mostly. Anderro gives you a prompt with your public key in it that adds the snippet and the sign-up call. You still add the secret key yourself in Lovable's Secrets and connect Stripe in Anderro.

Is my app on TanStack Start or the older React and Vite setup?

Lovable apps made since May 13, 2026 use TanStack Start, with a src/routes/__root.tsx file. Older apps have an index.html and use Supabase Edge Functions for server code.

Where does the secret key go in Lovable?

In More, then Settings, then Secrets, as ANDERRO_SECRET_KEY. Lovable may ask for it with a secure form in the chat: use that form, never the chat box, and never a VITE_ variable.

Does Anderro pay my affiliates?

No. Anderro tracks clicks, sign-ups and sales and works out what each affiliate earned. You pay affiliates yourself and mark the payout paid in Anderro.

Do my affiliates need an account on this platform?

No. They join your program on Anderro and get their link there. Their link is your site's address ending in ?ref= and their code.

Sources

Lovable's menus and plans change; these are the pages we checked.

  1. Lovable docs: Secrets, checked December 4, 2026
  2. Lovable docs: Upgrade to TanStack Start, checked December 4, 2026
  3. TanStack Start docs: Routing (__root.tsx), checked December 4, 2026
  4. Lovable: Affiliate partners, checked December 4, 2026

Lovable is a trademark of its owner. Anderro is not affiliated with or endorsed by them.

Other setup guides

All setup guides · How tracking works