Skip to main content

SvelteKit Affiliate Program Setup with Stripe

Know what must work before you launch

Connect browser referral capture to a server-side Stripe checkout

Best fit
Teams evaluating AffiliateBase for a Svelte affiliate workflow.
Checkout handoff
The checkout path must receive the generated AffiliateBase referral ID.
Proof required
Complete one referred checkout and confirm the attributed sale and commission.

Follow the attribution evidence

Illustrative scenario · fictional values

  1. Referred visit

    ?via=partner

    AffiliateBase captures the visit and generates a referral record.

  2. Checkout handoff

    referral ID

    The checkout must carry the generated identifier into Stripe.

  3. Paid event

    $99 paid

    A supported Stripe event confirms the attributed payment.

  4. Commission

    $19.80 due

    An eligible attributed sale creates the commission record.

  5. Payout prep

    Payout ready

    Review the commission and prepare the next step with your payout provider.

This guide is for merchants running an affiliate program in their own Svelte or SvelteKit app. A plain Svelte site can load the script in its HTML shell; SvelteKit projects can use app.html or an appropriate layout.

The generated referral ID exists in the browser. Submit it to the SvelteKit server route or form action that creates Stripe Checkout. A store can hold client state, but it does not attribute a payment by itself.

Use the Stripe checkout requirements and complete the verification checklist on a reachable deployment.

Connect the app shell, checkout request, and Stripe event:

1

Choose the Checkout Route

Locate the Svelte component that starts checkout and the SvelteKit server route or action that creates the session.
2

Install the Browser Script

Add the account-specific script to app.html, a shared layout, or the plain Svelte HTML shell so it loads on affiliate landing pages.
html
<script async src="https://app.affiliatebase.io/track.js" data-account-id="YOUR_ACCOUNT_ID"></script>
3

Pass Referral State Server-Side

Send the generated referral ID in the checkout request, validate it, and set Stripe client_reference_id with the documented metadata mirror.
4

Test the Published Flow

Open the generated test affiliate link and complete Stripe test checkout through the deployed app.
5

Confirm the Commission

Verify the completed checkout identifier, sale, and commission. A successful script load or webhook alone is incomplete.

What the SvelteKit Path Provides

Small Client Boundary

Only referral capture and checkout initiation need browser state.

Protected Checkout Creation

Stripe secret-key work remains in a server route or action.

Full-Path Verification

The test follows the buyer from affiliate link through commission creation.

SvelteKit Affiliate Tracking Questions

Does a Svelte store create attribution?
No. It can hold the generated referral ID, which must still be sent to the checkout server route.
Can server code read the browser global?
No. Submit the generated referral ID from the client.
How should I test?
Use the generated test link on a deployed app, complete checkout, and confirm the sale and commission.

Related Platform Guides

Verify Your SvelteKit Checkout

Test the same client and server path your customers use.