Developer Documentation

Everything you need to integrate ReferralAI into your application

Getting Started

Quick Start

Get up and running with ReferralAI in minutes. Follow these simple steps to integrate our tracking SDK into your application.

1

Include the SDK

Add the script tag to your HTML

2

Initialize

Set up with your API key

3

Track Events

Start tracking referrals

Installation

HTML
<script src="https://cdn.usereferralai.com/referral-tracker.min.js"></script>

Initialization

Initialize the SDK with your API key. You can find your API key in the admin dashboard under Settings → API Keys.

JavaScript
ReferralTracker.init('YOUR_API_KEY', {
  apiUrl: 'https://api.usereferralai.com/api/v1/referrals',
  debug: true
});

Tracking Events

Basic Tracking

Track a referral code usage when a user signs up or performs an action.

JavaScript
await ReferralTracker.track('CODE123', {
  platform: 'web',
  user_id: 'user_12345',
  user_name: 'John Doe',
  user_email: 'john@example.com',
  campaign: 'signup_2024'
});

REST API

Authentication

All API requests require authentication using a Bearer token.

HTTP Header
Authorization: Bearer YOUR_API_KEY

Base URL

All API endpoints are relative to:

https://api.usereferralai.com/api/v1

SDK Reference

ReferralTracker.init()

Initialize the SDK with your API key

apiKey string - Your API key
options object - Optional configuration

ReferralTracker.track()

Track a referral code usage

code string - The referral code
metadata object - Additional data

Examples

Complete Integration

A full example showing how to integrate ReferralAI into a signup form.

HTML + JavaScript
<form id="signupForm">
  <input type="text" id="name" required>
  <input type="email" id="email" required>
  <input type="text" id="referralCode" placeholder="Referral Code">
  <button type="submit">Sign Up</button>
</form>

<script>
  ReferralTracker.init('YOUR_API_KEY');

  document.getElementById('signupForm').addEventListener('submit', async (e) => {
    e.preventDefault();
    const code = document.getElementById('referralCode').value;

    if (code) {
      await ReferralTracker.track(code, {
        platform: 'web',
        user_name: document.getElementById('name').value,
        user_email: document.getElementById('email').value
      });
    }
  });
</script>

Support

Need help? We're here to assist you with your integration.