Testing Integration
Testing Integration
Section titled “Testing Integration”Before going live, test your integration to ensure tracking works correctly.
Enable Test Mode
Section titled “Enable Test Mode”Add data-affitor-debug="true" to your tracker script:
<script src="https://api.affitor.com/js/affitor-tracker.js" data-affitor-program-id="YOUR_PROGRAM_ID" data-affitor-debug="true"></script>Test mode:
- Logs all tracking events to browser console
- Events still sent to Affitor (marked as test)
- Visible in dashboard under test events
Test Checklist
Section titled “Test Checklist”1. Pageview Tracking (Click)
Section titled “1. Pageview Tracking (Click)”Steps:
- Open browser Developer Tools (F12) → Console
- Visit:
https://yoursite.com?ref=TEST123 - Look for Affitor debug messages
Expected console output:
[Affitor] Detected ref parameter: TEST123[Affitor] Setting partner_code cookie: TEST123[Affitor] Generated customer_code: cust_abc123[Affitor] Click event trackedVerify cookies:
- Developer Tools → Application → Cookies
- Check for
partner_code = TEST123 - Check for
customer_code = some value
Dashboard check:
- Go to Affitor → Integration Status
- Pageview tracker: ✅ Connected
2. Lead Tracking (Signup)
Section titled “2. Lead Tracking (Signup)”Steps:
- With cookies set (from step 1), complete your signup flow
- Check console for lead event
Expected console output:
[Affitor] trackLead called with: { email: 'test@example.com' }[Affitor] Lead event trackedDashboard check:
- Go to Affitor → Integration Status
- Referrals tracker: ✅ Connected
3. Payment Tracking (Sale)
Section titled “3. Payment Tracking (Sale)”Steps:
- Use Stripe test mode (test card:
4242 4242 4242 4242) - Complete a test purchase
- Check Stripe Dashboard → Webhooks for delivery status
Verify metadata (Stripe Dashboard):
- Go to Payments → find test payment
- Click to view details
- Check metadata contains:
partner_code: TEST123customer_code: cust_abc123program_id: YOUR_PROGRAM_ID
Dashboard check:
- Go to Affitor → Transactions
- Test conversion should appear
- Integration Status → Payments tracker: ✅ Connected
Test API Endpoint
Section titled “Test API Endpoint”Programmatically verify integration:
POST https://api.affitor.com/api/tracking/testContent-Type: application/json
{ "program_id": "YOUR_PROGRAM_ID", "step_id": "pageview"}Response:
{ "success": true, "message": "Test event received", "testEvent": { "id": "evt_123", "event_type": "test", "timestamp": "2026-01-21T12:00:00Z" }}Integration Status Dashboard
Section titled “Integration Status Dashboard”Check all three integrations at once:
- Go to Affitor Dashboard
- Navigate to Settings → Integration
- View status for each tracker:
| Tracker | Status | Meaning |
|---|---|---|
| Pageview | ✅ Connected | Script installed, receiving clicks |
| Referrals | ✅ Connected | Receiving lead events |
| Payments | ✅ Connected | Webhook configured, receiving sales |
| Tracker | Status | Meaning |
|---|---|---|
| Pageview | ⏳ Pending | Script not detected yet |
| Referrals | ⏳ Pending | No lead events received |
| Payments | ⏳ Pending | No payment events received |
Common Test Scenarios
Section titled “Common Test Scenarios”Scenario 1: Full Flow Test
Section titled “Scenario 1: Full Flow Test”- Open incognito window (fresh cookies)
- Visit
yoursite.com?ref=TEST123 - Sign up with test email
- Purchase with Stripe test card
- Check dashboard for: 1 click → 1 signup → 1 conversion
Scenario 2: Returning Visitor
Section titled “Scenario 2: Returning Visitor”- Visit
yoursite.com?ref=PARTNER_A - Leave site
- Return directly to
yoursite.com(no ref) - Purchase
Expected: Attributed to PARTNER_A (cookie persists)
Scenario 3: Partner Override
Section titled “Scenario 3: Partner Override”- Visit
yoursite.com?ref=PARTNER_A - Later visit
yoursite.com?ref=PARTNER_B - Purchase
Expected: Attributed to PARTNER_B (last click wins)
Scenario 4: Expired Attribution
Section titled “Scenario 4: Expired Attribution”- Visit
yoursite.com?ref=PARTNER_A - Wait 61+ days (or manually clear cookies)
- Purchase
Expected: No attribution (outside 60-day window)
Troubleshooting Test Issues
Section titled “Troubleshooting Test Issues”Console Shows No Affitor Messages
Section titled “Console Shows No Affitor Messages”Check:
data-affitor-debug="true"is set- Script URL is correct
- No ad blockers/privacy extensions
Cookies Not Setting
Section titled “Cookies Not Setting”Check:
- URL has
?ref=parameter - Site uses HTTPS
- No Content Security Policy blocking
Webhook Not Firing
Section titled “Webhook Not Firing”Check:
- Stripe webhook endpoint configured
- Correct events selected
- Endpoint URL is correct (
https://api.affitor.com/api/stripe/webhooks)
Test Event Not in Dashboard
Section titled “Test Event Not in Dashboard”Check:
- Program ID is correct
- Backend API is reachable
- Check Network tab for failed requests
Going Live
Section titled “Going Live”Once all tests pass:
-
Remove test mode:
data-affitor-debug="true" -
Switch Stripe to live mode (if using test mode)
-
Verify one real transaction before announcing to partners
-
Monitor dashboard for first few days
Support
Section titled “Support”If tests fail after checking troubleshooting steps:
- Screenshot console errors
- Note which step fails
- Contact support@affitor.com
Include:
- Program ID
- Browser and version
- Steps to reproduce