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.
Include the SDK
Add the script tag to your HTML
Initialize
Set up with your API key
Track Events
Start tracking referrals
Installation
<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.
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.
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.
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
ReferralTracker.track()
Track a referral code usage
Examples
Complete Integration
A full example showing how to integrate ReferralAI into a signup form.
<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.