Skip to main content

Adding Refindie to Your Website

Install tracking script and integrate with your payment system.

Integration Steps

1. Add the tracking script

Copy and paste the script below in the <head> section of your website. Script Parameters:
  • data-program-id - Your affiliate program ID (required)

2. Get referral data

The script sets a global object with referral information:
  • refindie_metadata.program_id (string | number)
  • refindie_metadata.ref_code (string)
  • refindie_metadata.is_new_visit (boolean)

3. Send data during payment

Include referral data in your payment API calls to attribute commissions.

Integration Options

  1. Connect your Stripe account in Settings > Integration
  2. Pass the referral metadata to Stripe Checkout using the metadata field (exactly the object from window.refindie_metadata)
For subscriptions: Always pass window.refindie_metadata in the checkout session’s metadata field. Do NOT use subscription_data: { metadata: window.refindie_metadata } — this places metadata on the subscription object instead of the checkout session, which prevents commission tracking from working.
  • Professional payment processing
  • Commission tracking via Stripe metadata
  • Payment history and manual payout verification

Option 2: Referral API

Use the server-to-server endpoint when you use a custom payment provider or want to record a referral manually.
  • Endpoint: POST /api/referral
  • Headers: x-api-key: <YOUR_PROGRAM_API_KEY>
  • Body (JSON):
    • ref_code (string)
    • program_id (string | number)
    • spent_amount (number, in cents)
    • currency (string, e.g. “USD”)
    • transaction_id (string, unique)

Implementation Examples

React Component (Next.js)

API Route (app/api/checkout/route.ts)

AI Assistant Prompt

Copy this prompt into your AI assistant to implement this feature:

Tips and Help

💡 Important Tips

  • Add the script to all your pages to never miss a referral
  • Referral data is available as soon as the script is loaded
  • Test the integration in development mode before production
  • Subscriptions: The first payment is tracked via the checkout session metadata. Renewal payments are tracked automatically using the subscription ID — no extra work needed
  • Never put referral metadata in subscription_data.metadata — always use the checkout session’s metadata field

✅ Verification

To verify that the integration works, open your browser console and type window.refindie_metadata. You should see the referral data.

Support

If you encounter any difficulties, contact us at contact@refindie.com or consult our documentation.