How to add an affiliate program to your Replit app
Create a program on Anderro, ask Replit Agent to add the tracking snippet, keep your secret key in Replit's Secrets, and pass the visitor ID in the route that creates your Stripe checkout. Then republish.
Replit steps last checked December 4, 2026.
Replit at a glance
| Snippet | The shared HTML page or layout, or let Replit Agent add it |
|---|---|
| Secret key | Tools › Secrets |
| Payments | Replit's Stripe connector or your own Stripe key |
| Plan needed | A deployment that can read secrets (Autoscale or Reserved VM) |
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: paste the prompt Anderro gives you into Replit Agent.
By hand: in the HTML page or layout every page shares, inside <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 Replit, open Tools, then Secrets (under Setup), and add ANDERRO_SECRET_KEY. Static deployments cannot read secrets; use an Autoscale or Reserved VM deployment.
On the server, after the account is created, send the sign-up with your secret key and the visitor ID the browser sent.
// 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 in the server route that creates the Checkout Session, whether it uses Replit's Stripe connector or your own Stripe key.
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
Republish the deployment so the change goes live.
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 Replit
Paste this into Replit'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 Replit
- Your
*.replit.devaddress is a private development URL. Anderro only counts your published*.replit.appaddress or your own domain. - 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
Stripe test webhooks do not reach my workspace
Your replit.dev address is private and can change. Test the whole flow on the published replit.app address instead.
The secret key is undefined in production
Static deployments cannot read secrets. Switch to an Autoscale or Reserved VM deployment and republish.
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 Replit have its own affiliate program?
Replit runs a partner program with integration, solution, government and education tracks; solution partners and resellers get a referral and co-selling program. That pays you for promoting Replit. 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.
Why does nothing show up while I test in the workspace?
The workspace runs on a private replit.dev address that Anderro treats as a preview. Test on your published app instead.
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
Replit's menus and plans change; these are the pages we checked.
- Replit docs: Secrets, checked December 4, 2026
- Replit docs: Development URLs, checked December 4, 2026
- Replit docs: Publish your app, checked December 4, 2026
- Replit: Partner programs, checked December 4, 2026
Replit is a trademark of its owner. Anderro is not affiliated with or endorsed by them.