Testing Your Integration

Verify your AffiliateBase setup is working correctly

Table of Contents

Testing Your Integration

Before inviting affiliates, verify your AffiliateBase integration is working correctly. This guide walks through testing each component.

Prerequisites

Before testing, ensure you have:

Step 1: Test the Tracking Script

Verify Script Loads

  1. Open your website in a browser
  2. Open Developer Tools (F12 or right-click → Inspect)
  3. Go to the Console tab
  4. Look for: AffiliateBase: Initialized

Check for Errors

In the Console, look for any red error messages mentioning:

  • affiliatebase
  • Failed to load resource
  • Content Security Policy

No errors? Your script is loading correctly.

Step 2: Test Referral Tracking

Visit your site with a referral parameter:

https://yoursite.com?via=test

Or use an actual affiliate’s token:

https://yoursite.com?via=affiliate-token

Verify Referral Capture

In the browser console, run:

console.log(window.affiliatebase_referral);

You should see a referral ID string like:

"abc123-def456-ghi789"

Check Cookies

  1. Go to Application tab (Chrome) or Storage tab (Firefox)
  2. Expand Cookies → your domain
  3. Look for ab_referral cookie

The cookie should contain referral data.

Step 3: Test Conversion Tracking

Make a Test Purchase

  1. Click an affiliate link to your site
  2. Add a product to cart
  3. Complete checkout with Stripe
  4. Use Stripe test card: 4242 4242 4242 4242

Verify in Dashboard

After the test purchase:

  1. Open your AffiliateBase dashboard
  2. Go to Dashboard or Referrals
  3. Look for the new conversion
  4. Verify it’s attributed to the correct affiliate

Check Stripe Webhook

  1. Go to your Stripe Dashboard
  2. Navigate to DevelopersWebhooks
  3. Find the AffiliateBase endpoint
  4. Check recent webhook deliveries
  5. Verify invoice.paid events show 200 status

Step 4: Test the Affiliate Portal

If you set up an affiliate portal:

  1. Log in as an affiliate (or use your test affiliate account)
  2. Verify the dashboard loads
  3. Check that referral links are displayed
  4. Confirm earnings show correctly

Common Testing Issues

”window.affiliatebase_referral is undefined”

Cause: Script hasn’t loaded yet, or you’re on localhost.

Solutions:

  • Wait 1-2 seconds after page load
  • Test on a deployed site (not localhost)
  • Check that the script is in your HTML

”No conversion appeared in dashboard”

Causes:

  • Webhook didn’t fire
  • Referral cookie wasn’t set
  • client_reference_id not passed to Stripe

Solutions:

  1. Check Stripe webhook logs for errors
  2. Verify cookie exists before checkout
  3. Ensure you’re passing client_reference_id in checkout

”Conversion shows but wrong affiliate”

Cause: Referral was attributed to a different affiliate.

Check:

  1. What cookie value was set?
  2. Was there a previous referral?
  3. Is promo code attribution overriding link attribution?

”Test works but production doesn’t”

Causes:

  • Different script configuration
  • Missing script on some pages
  • Environment variable issues

Solutions:

  1. Compare test and production HTML
  2. Verify organization ID is correct for production
  3. Check all checkout pages have the script

Testing Checklist

Use this checklist to verify your setup:

  • Tracking script loads without errors
  • window.affiliatebase_referral populated after clicking affiliate link
  • ab_referral cookie is set
  • Test purchase completes successfully
  • Conversion appears in AffiliateBase dashboard
  • Commission calculated correctly
  • Affiliate can see earnings in their portal

Debugging Tools

Browser Console Commands

// Check if script loaded
console.log(typeof window.affiliatebase);

// Get current referral
console.log(window.affiliatebase_referral);

// Get full referral object
console.log(window.AffiliateBase?.referral);

// Check cookies
console.log(document.cookie);

Network Tab

Monitor requests to:

  • cdn.jsdelivr.net (script loading)
  • api.affiliatebase.com/api/track (tracking calls)

Stripe Webhook Logs

In Stripe Dashboard → Developers → Webhooks:

  • View delivery attempts
  • Check response codes
  • Resend failed webhooks for testing

Test Mode vs Live Mode

Stripe Test Mode

When testing:

  • Use Stripe test API keys
  • Use test card numbers
  • Transactions don’t involve real money
  • Webhooks still fire normally

Test Card Numbers

Card NumberDescription
4242 4242 4242 4242Successful payment
4000 0000 0000 0002Card declined
4000 0000 0000 32203D Secure required

Use any future expiration date and any 3-digit CVC.

Next Steps

Once testing is complete: