Documentation

Everything you need to integrate and use LeadFnF

Getting Started

Quick Start Guide

1

Create Your Account

Sign up at https://leadfnf.com/register and complete your profile setup.

2

Get Your API Keys

Navigate to Settings > API Keys and generate your production and sandbox keys.

3

Add Tracking Code

Install our JavaScript tracking snippet on your website (shown below).

4

Connect Your Platform

Integrate with Stripe, Shopify, WooCommerce, or use our API.

5

Start Tracking

Test your integration and start inviting affiliates!

Installation

Add this JavaScript snippet to your website, just before the closing </body> tag:

<script> (function(w,d,s,l,i){ w[l]=w[l]||[]; w[l].push({'event':'affiliate.init','api_key':i}); var f=d.getElementsByTagName(s)[0], j=d.createElement(s); j.async=true; j.src='https://cdn.affiliatehub.com/tracker.js'; f.parentNode.insertBefore(j,f); })(window,document,'script','affiliateLayer','YOUR_API_KEY'); </script>

Important

Replace YOUR_API_KEY with your actual API key from the dashboard.

Testing Your Integration

Use these test parameters to verify your tracking is working:

Test Affiliate Link: https://yoursite.com/?ref=TEST123
Verify Tracking:

Open your browser's developer console and look for LeadFnF tracking events.

Check Dashboard:

Clicks should appear in your dashboard within seconds.

Integration Guides

Stripe Integration

Connect your Stripe account to automatically track payments and attribute them to affiliates.

Navigate to Integrations > Stripe in your dashboard
Click "Connect with Stripe" and authorize access
Payments are automatically tracked and attributed
Supports subscriptions and one-time payments

Code Example:

// Add affiliate reference to Stripe metadata const session = await stripe.checkout.sessions.create({ payment_method_types: ['card'], line_items: [lineItems], metadata: { affiliate_ref: 'AFFILIATE_CODE' } });

Shopify Integration

Install our Shopify app to automatically track orders from affiliate referrals.

Install the LeadFnF app from Shopify App Store
Enter your LeadFnF API key
Orders are automatically synced in real-time
Works with all Shopify plans and themes

WooCommerce

Free WordPress plugin for seamless WooCommerce integration.

Download and install our WordPress plugin
Add your API key in plugin settings
Configure commission rules per product
Track orders and coupon code usage

Custom API

Build your own integration using our RESTful API.

Full REST API with complete documentation
Code examples in multiple languages
Sandbox environment for testing
Webhook support for real-time updates

API Reference

Base URL

https://api.affiliatehub.com/v1

Authentication

All API requests require authentication using your API key in the header:

Authorization: Bearer YOUR_API_KEY

Track Click

POST
/clicks

Record an affiliate click when a user clicks on an affiliate link.

Request Body:

{ "affiliate_code": "ABC123", "url": "https://example.com/product", "ip_address": "192.168.1.1", "user_agent": "Mozilla/5.0...", "referrer": "https://affiliate-site.com" }

Response:

{ "success": true, "click_id": "clk_1234567890", "tracking_cookie": "af_track_xyz123" }

Track Conversion

POST
/conversions

Record a conversion when a referred user makes a purchase.

Request Body:

{ "affiliate_code": "ABC123", "order_id": "ord_1234567890", "order_value": 99.99, "currency": "USD", "customer_email": "customer@example.com", "metadata": { "product_id": "prod_123" } }

Response:

{ "success": true, "conversion_id": "conv_1234567890", "commission_amount": 9.99, "commission_rate": 10 }

Get Affiliate

GET
/affiliates/:code

Retrieve information about a specific affiliate.

Response:

{ "id": 123, "code": "ABC123", "name": "John Doe", "email": "john@example.com", "status": "active", "commission_rate": 10, "total_clicks": 1523, "total_conversions": 87, "total_commission": 1234.56 }

List Affiliates

GET
/affiliates?page=1&limit=20

Get a paginated list of all affiliates.

Query Parameters:

Parameter
Type
Description
page
integer
Page number (default: 1)
limit
integer
Results per page (default: 20)
status
string
Filter by status (active, pending, suspended)

Code Examples

JavaScript

const response = await fetch( 'https://api.affiliatehub.com/v1/clicks', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ affiliate_code: 'ABC123', url: window.location.href }) } ); const data = await response.json();

PHP

$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://api.affiliatehub.com/v1/clicks'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json' ]); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([ 'affiliate_code' => 'ABC123', 'url' => $_SERVER['REQUEST_URI'] ]) ); $response = curl_exec($ch);

Python

import requests url = 'https://api.affiliatehub.com/v1/clicks' headers = { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' } data = { 'affiliate_code': 'ABC123', 'url': 'https://example.com/product' } response = requests.post(url, headers=headers, json=data)

cURL

curl -X POST \ https://api.affiliatehub.com/v1/clicks \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "affiliate_code": "ABC123", "url": "https://example.com/product" }'

Webhooks

What are Webhooks?

Webhooks allow LeadFnF to send real-time notifications to your server when specific events occur. Instead of polling our API for changes, we'll send an HTTP POST request to your configured endpoint whenever an event happens.

Setup

  1. 1 Go to Settings > Webhooks in your dashboard
  2. 2 Click "Add Webhook" and enter your endpoint URL
  3. 3 Select which events you want to receive
  4. 4 Save and test your webhook

Available Events

click.created

Triggered when a new click is tracked

conversion.created

Triggered when a conversion is recorded

affiliate.approved

Triggered when an affiliate is approved

affiliate.suspended

Triggered when an affiliate is suspended

commission.paid

Triggered when a commission is paid out

Webhook Payload Example

{ "event": "conversion.created", "timestamp": "2024-01-15T10:30:00Z", "data": { "conversion_id": "conv_1234567890", "affiliate_code": "ABC123", "order_id": "ord_1234567890", "order_value": 99.99, "commission_amount": 9.99, "currency": "USD", "customer_email": "customer@example.com" } }

Webhook Signature Verification

Verify webhook signatures to ensure requests are coming from LeadFnF:

// PHP Example $payload = file_get_contents('php://input'); $signature = $_SERVER['HTTP_X_AFFILIATEHUB_SIGNATURE']; $secret = 'your_webhook_secret'; $expected = hash_hmac('sha256', $payload, $secret); if (hash_equals($expected, $signature)) { // Signature is valid $data = json_decode($payload, true); // Process the webhook... } else { // Invalid signature http_response_code(401); }

Link Tracking Guide

Affiliate Link Structure

Affiliate links use a simple query parameter structure:

https://yoursite.com/?ref=AFFILIATE_CODE

You can also use custom parameters:

https://yoursite.com/products/?aff=AFFILIATE_CODE

Cookie Duration

When a user clicks an affiliate link, we set a cookie that persists for your configured duration (default: 30 days). Any conversion within this period is attributed to the affiliate.

Cookie Behavior:

  • First-party cookies for better tracking
  • Configurable expiration (7, 30, 60, 90 days)
  • Last-click attribution model
  • Secure and HttpOnly flags for security

UTM Parameters

Add UTM parameters to track campaign performance:

https://yoursite.com/?ref=ABC123 &utm_source=affiliate &utm_medium=referral &utm_campaign=summer_sale

Deep Linking

Affiliates can link to any page on your site:

Homepage:
https://yoursite.com/?ref=ABC123
Product Page:
https://yoursite.com/products/item?ref=ABC123
Category Page:
https://yoursite.com/category/shoes?ref=ABC123

Commission Structure Setup

Percentage-Based

Pay a percentage of each sale to affiliates.

Example:
10%
$100 sale = $10 commission

Fixed Amount

Pay a flat amount per conversion.

Example:
$25
Per sale, regardless of amount

Tiered Structure

Reward top performers with higher rates.

0-10 sales: 10%
11-50 sales: 12%
51+ sales: 15%

Commission Rules

Product-Specific Commissions

Set different commission rates for specific products or categories:

Product/Category
Commission
Premium Products
15%
Standard Products
10%
Clearance Items
5%

Recurring Commissions

For subscription-based businesses, set up recurring commission payments:

  • Lifetime commissions on all subscription payments
  • First month only commissions
  • First X months commissions (e.g., 3, 6, 12 months)

Troubleshooting

Clicks Not Being Tracked

Possible Causes:
  • Tracking code not properly installed
  • Ad blockers preventing tracking script
  • Incorrect API key in tracking code
  • JavaScript errors on page
Solutions:
  • Verify tracking code is in <body> section
  • Check browser console for errors
  • Test with ad blockers disabled
  • Verify API key matches dashboard

Conversions Not Attributing Correctly

Possible Causes:
  • Cookie not being set properly
  • User clearing cookies between click and conversion
  • Conversion tracking code missing
  • Wrong affiliate code in conversion call
Solutions:
  • Ensure tracking code is on all pages
  • Verify cookie domain settings
  • Test with browser console monitoring
  • Check conversion API call parameters

API Authentication Errors

Possible Causes:
  • Invalid or expired API key
  • Using sandbox key in production
  • Missing Authorization header
  • Incorrect header format
Solutions:
  • Regenerate API key in dashboard
  • Verify using correct environment key
  • Check header format: Bearer YOUR_KEY
  • Test with cURL example from docs

Webhooks Not Receiving Events

Possible Causes:
  • Endpoint URL not accessible
  • Webhook endpoint returning errors
  • SSL certificate issues
  • Firewall blocking requests
Solutions:
  • Verify endpoint is publicly accessible
  • Check webhook logs in dashboard
  • Ensure endpoint returns 200 status
  • Test with webhook testing tools

Still Need Help?

Can't find what you're looking for? Our support team is here to help!

Ready to Get Started?

Start building your affiliate program today with LeadFnF.

Start Free Trial

No credit card required • 14-day free trial • Cancel anytime