# Add an affiliate program to your app with LinkJolt

> For founders and their coding agents (Claude Code, Codex, Cursor). Web page: https://www.linkjolt.io/developers/quickstart

LinkJolt is affiliate software for SaaS. It tracks the sales affiliates bring in through their links and discount codes, straight from the merchant's own payment provider (Stripe, Paddle, Polar, Creem, Lemon Squeezy, Gumroad and more), gives affiliates a portal, and pays them through Stripe payouts or a PayPal or Wise file. LinkJolt never holds the money.

The integration is one script tag and, for checkouts the server creates, one field. Nothing to install from npm.

## 1. Create your LinkJolt account (the person, in a browser)

Sign up at https://www.linkjolt.io/auth/sign-up. Plans start at $19.99 a month, with a 7-day free trial (card required) and 0% of your sales taken.

Create a campaign: the commission (for example 20% of every payment, renewals included) and the page affiliate links send people to.

Working in Claude Code or Codex? Add the LinkJolt connector (below) and your agent can read your setup and tracking script and name the business before you pick a plan, then create the campaign once your trial has started. You sign in once in the browser.

## 2. Connect where you take payment (the person, in a browser)

In LinkJolt, open Integrations and pick your provider. This is the step that sends sales to LinkJolt, and it happens in your browser: an agent cannot approve it for you.

- Stripe: Integrations → Stripe → Set up with Stripe, then approve once on Stripe. No webhook to create, no secret to paste.
- Paddle: Integrations → Paddle → paste a Paddle API key that can write notification settings. LinkJolt creates the notification destination.
- Polar: Integrations → Polar → approve once. LinkJolt creates the webhook.
- Creem: Integrations → Creem → paste a Creem API key. LinkJolt creates the webhook.
- Lemon Squeezy and Gumroad: add the webhook LinkJolt shows on that Integrations tab.
- Everything else: follow that platform's Integrations tab; the platform files in step 4 have the same steps.

## 3. Add the tracking script (the agent, in code)

Put the script on every page of the site, in the root layout. Your merchant id is in the script tag shown on Integrations (or ask the connector for it).

When a visitor arrives through an affiliate link (?tc=...&aff=...), the script keeps the referral for 30 days and exposes it as window.linkjolt.referral, a string like tc_abc_aff_xyz_cid_123. On a visit without an affiliate it is empty.

```tsx
import Script from 'next/script';

// inside <body> of the root layout
<Script src="https://www.linkjolt.io/api/tracking.js?id=YOUR_MERCHANT_ID" strategy="afterInteractive" />
```

```html
<script src="https://www.linkjolt.io/api/tracking.js?id=YOUR_MERCHANT_ID" async></script>
```

TypeScript projects can declare the global once:

```typescript
// global.d.ts, so window.linkjolt type-checks
interface Window {
  linkjolt?: { referral: string | null };
}
```

## 4. Pass the referral to checkout (the agent, in code)

Find how the app takes payment and make the one change for it. Never rename the field or put the referral anywhere else: that field is what LinkJolt reads. Renewals, refunds and plan changes are tracked from the first payment, so there is nothing to build for them.

### Stripe Checkout, created by your server

- Spot it: the stripe package, and stripe.checkout.sessions.create in a route or server action.
- Connect (the person, in LinkJolt): Integrations → Stripe → Set up with Stripe, then approve once on Stripe. No webhook to create.
- Change: Read window.linkjolt.referral in the browser, send it with the checkout request, and set it as client_reference_id on the Checkout Session.
- Full steps: https://www.linkjolt.io/developers/quickstart/stripe.md

```typescript
// Browser: the page that starts checkout
const referral = window.linkjolt?.referral || '';
const res = await fetch('/api/checkout', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ priceId, referral }),
});

// Server: where the Checkout Session is created
const { priceId, referral } = await req.json();
const session = await stripe.checkout.sessions.create({
  // ...your existing options
  client_reference_id: referral || undefined,
});
```

### Stripe Payment Links, pricing table or buy button

- Spot it: buy.stripe.com links, <stripe-pricing-table> or <stripe-buy-button>.
- Connect (the person, in LinkJolt): Integrations → Stripe → Set up with Stripe, then approve once on Stripe.
- Change: Nothing beyond the tracking script: it adds the referral to every buy.stripe.com link and sets client-reference-id on the pricing table and buy button.
- Full steps: https://www.linkjolt.io/developers/quickstart/payment-links.md

### Paddle Billing (Paddle.js checkout)

- Spot it: @paddle/paddle-js, Paddle.Checkout.open or paddle.Checkout.open.
- Connect (the person, in LinkJolt): Integrations → Paddle → paste a Paddle API key that can write notification settings. LinkJolt creates the notification destination.
- Change: Pass the referral as customData.linkjolt when opening Paddle Checkout.
- Full steps: https://www.linkjolt.io/developers/quickstart/paddle.md

```typescript
paddle.Checkout.open({
  items: [{ priceId, quantity: 1 }],
  customData: { linkjolt: window.linkjolt?.referral || '' },
});
```

### Polar

- Spot it: @polar-sh/sdk, or links to buy.polar.sh.
- Connect (the person, in LinkJolt): Integrations → Polar → approve once. LinkJolt creates the webhook.
- Change: Checkout links need nothing beyond the script. A checkout your server creates sets the referral as metadata.reference_id.
- Full steps: https://www.linkjolt.io/developers/quickstart/polar.md

```typescript
const checkout = await polar.checkouts.create({
  products: [productId],
  successUrl,
  metadata: referral ? { reference_id: referral } : {},
});
```

### Creem

- Spot it: the creem package, creem.io payment or product links.
- Connect (the person, in LinkJolt): Integrations → Creem → paste a Creem API key. LinkJolt creates the webhook.
- Change: Payment links need nothing beyond the script. A checkout your server creates sets the referral as metadata.linkjolt_ref.
- Full steps: https://www.linkjolt.io/developers/quickstart/creem.md

```typescript
import { Creem } from "creem";
const creem = new Creem({ apiKey: process.env.CREEM_API_KEY });

const checkout = await creem.checkouts.create({
  productId: "prod_123",
  successUrl: "https://example.com/thanks",
  metadata: { linkjolt_ref: referral },   // the value from window.linkjolt.referral
});
// send the customer to checkout.checkoutUrl
```

### Lemon Squeezy or Gumroad links

- Spot it: links to *.lemonsqueezy.com, *.gumroad.com or gum.co.
- Connect (the person, in LinkJolt): Add the webhook LinkJolt gives you in the provider (the file below has the address and the steps).
- Change: Nothing beyond the tracking script: it adds the referral to those links.
- Full steps: https://www.linkjolt.io/developers/quickstart/payment-links.md

### Other platforms

- WooCommerce: https://www.linkjolt.io/developers/quickstart/woocommerce.md
- Squarespace: https://www.linkjolt.io/developers/quickstart/squarespace.md
- BigCommerce: https://www.linkjolt.io/developers/quickstart/bigcommerce.md
- Teachable: https://www.linkjolt.io/developers/quickstart/teachable.md
- Carrd: https://www.linkjolt.io/developers/quickstart/carrd.md
- Webflow: https://www.linkjolt.io/developers/quickstart/webflow.md
- GoPay: https://www.linkjolt.io/developers/quickstart/gopay.md
- Fourthwall: https://www.linkjolt.io/developers/quickstart/fourthwall.md
- Apple In-App Purchases: https://www.linkjolt.io/developers/quickstart/apple-iap.md
- Shopify app billing: https://www.linkjolt.io/developers/quickstart/shopify-app-billing.md

## 5. Check it with a test sale (the agent, in code)

Open the site with ?tc=TEST&aff=TEST and run window.linkjolt.referral in the browser console: it should print tc_TEST_aff_TEST.

For a real check, use the test link on the Integrations page and buy in your provider's test mode. With Set up with Stripe, a Stripe test-mode purchase is recorded as a test sale (a Stripe sandbox is a separate account, so it is not). Creem test-mode purchases and Paddle sandbox purchases with a sandbox key connected are test sales too. Test sales are listed under Commissions → Test sales, apart from real commissions.

## Rules for agents

- Use the provider's own checkout; LinkJolt does not replace it, and no npm package is needed.
- There is no referral table, commission logic or payout code to write: LinkJolt records each sale from the payment provider, works out the commission, reverses it on a refund, gives affiliates their sign-up page and portal, and pays them through Stripe payouts or a PayPal or Wise file.
- Keep secrets server-side. The tracking script is public; API keys are not.
- Connecting the payment provider and starting a plan are the person's steps in the browser. Say which page to open, then carry on with the code.

## Let your agent do the LinkJolt side

The LinkJolt connector (MCP, https://www.linkjolt.io/api/mcp) lets an agent read the setup status and the merchant's own tracking script and name the business, and once a trial has started, create the campaign and invite the first affiliate. Sign-in is OAuth in the browser, with no API key to paste, and a new account can connect before picking a plan. Other clients, Cursor included: https://www.linkjolt.io/developers/mcp

```bash
claude mcp add --transport http --scope user linkjolt https://www.linkjolt.io/api/mcp
# then inside Claude Code: /mcp, pick linkjolt, authenticate
```

```bash
codex mcp add linkjolt --url https://www.linkjolt.io/api/mcp
codex mcp login linkjolt
```

The LinkJolt skill walks an agent through this page and installs in Claude Code, Codex, Cursor and other agents:

```bash
npx skills add https://www.linkjolt.io
```

## More

- Developer docs: https://www.linkjolt.io/developers
- Connector docs: https://www.linkjolt.io/developers/mcp
- Plans: https://www.linkjolt.io/pricing
- Support: ollie@linkjolt.io
