Script Not Loading
If the AffiliateBase tracking script isn’t working properly, this guide helps you diagnose and fix common issues.
Quick Diagnosis
Check Script is Present
- Right-click on your page → View Page Source
- Search for
affiliatebaseorjsdelivr - Verify the script tags are present
Expected code:
<script>
(function(w,r){
w._abq=w._abq||[];
w[r]=w[r]||function(){(w[r].q=w[r].q||[]).push(arguments)}
})(window,'affiliatebase');
</script>
<script
async
src="https://cdn.jsdelivr.net/npm/affiliatebase-tracking@1/src/index.js"
data-org-id="YOUR_ORG_ID">
</script>
Check Console for Errors
- Open Developer Tools (F12 or right-click → Inspect)
- Go to the Console tab
- Look for red error messages
- Search for messages containing “affiliatebase”
Check Network Tab
- Open Developer Tools
- Go to Network tab
- Filter by “affiliatebase” or “jsdelivr”
- Look for the script request
- Check status (should be 200)
Common Issues & Solutions
Issue: Script Not in HTML
Symptom: Script tags not found in page source.
Solutions:
- Verify you added the script to your template/theme
- Check it’s in the correct section (
<head>recommended) - Clear any caching (CDN, browser, CMS cache)
- Verify the page uses the correct template
Issue: Wrong Organization ID
Symptom: Script loads but no tracking occurs.
Solutions:
- Go to AffiliateBase dashboard
- Copy your Organization ID from setup
- Update
data-org-idin your script - Deploy changes
<!-- Verify this matches your dashboard -->
<script ... data-org-id="correct-org-id"></script>
Issue: Script Blocked by Ad Blocker
Symptom: Network request blocked or failed.
Solutions:
- Disable ad blocker temporarily to test
- Check if your ad blocker has strict rules
- Test in incognito/private mode
- Consider using npm package instead of CDN
Issue: Content Security Policy (CSP) Blocking
Symptom: Console shows CSP violation error.
Error example:
Refused to load script from 'https://cdn.jsdelivr.net/...'
because it violates Content-Security-Policy
Solutions: Add jsdelivr.net to your CSP header:
Content-Security-Policy: script-src 'self' https://cdn.jsdelivr.net;
Or in meta tag:
<meta http-equiv="Content-Security-Policy"
content="script-src 'self' https://cdn.jsdelivr.net;">
Issue: CORS Error
Symptom: Console shows CORS-related error.
Solutions:
- CORS errors usually indicate a configuration issue
- Verify you’re loading from the official CDN
- Check your server isn’t proxying incorrectly
- Ensure no conflicting headers
Issue: Script Loading Too Late
Symptom: Script loads but window.affiliatebase_referral is undefined when accessed.
Solutions:
- Place script in
<head>not bottom of body - Wait for script to initialize:
// Wait for script to be ready
window._abq = window._abq || [];
window._abq.push(function() {
console.log('Referral:', window.affiliatebase_referral);
});
- Or check before accessing:
// Check if ready
if (window.AffiliateBase) {
console.log(window.affiliatebase_referral);
} else {
// Script not loaded yet
}
Issue: Multiple Script Instances
Symptom: Unexpected behavior, duplicate tracking.
Solutions:
- Search your code for multiple script inclusions
- Check theme/plugin conflicts
- Ensure script is only loaded once per page
Issue: Localhost Testing
Symptom: Script loads but window.affiliatebase_referral is undefined on localhost.
Explanation: The tracking script doesn’t create referrals on localhost by design (security measure).
Solutions:
- Test on a deployed site (staging or production)
- Use a tunneling service (ngrok, localhost.run)
- Deploy to a test environment
Verification Steps
Step 1: Confirm Script Loads
In console, run:
typeof window.affiliatebase
// Should return "function"
Step 2: Check Initialization
Look for console message:
AffiliateBase: Initialized with org YOUR_ORG_ID
Step 3: Test Referral Capture
- Visit:
https://yoursite.com?via=test - In console, run:
console.log(window.affiliatebase_referral);
// Should output a referral ID
Step 4: Check Cookies
- Go to Developer Tools → Application → Cookies
- Look for
ab_referralcookie - Should contain referral data
Step 5: Check Network Request
- Visit with
?via=testparameter - Look for request to
api.affiliatebase.com/api/track - Should return 200 status
Platform-Specific Issues
WordPress
- Check theme’s header.php has the script
- Verify caching plugins aren’t removing it
- Try adding via a plugin like “Insert Headers and Footers”
Webflow
- Add to Project Settings → Custom Code → Head Code
- Publish changes
- Clear Webflow CDN cache
Shopify
- Add to theme.liquid in
<head>section - Or use Google Tag Manager
- Clear Shopify cache
React/Next.js
- Use
next/scriptcomponent for proper loading - Add to
_app.jsor_document.js - Verify it’s not being removed by build process
Single Page Applications
- Ensure script loads on initial page load
- Script persists across client-side navigation
- No need to reinitialize on route changes
Still Not Working?
Gather Diagnostic Info
Before contacting support, collect:
- Screenshot of console errors
- Screenshot of network tab (filtered to affiliatebase)
- Your website URL
- Your organization ID
- Browser and version
- Steps to reproduce
Contact Support
Email support@affiliatebase.com with:
- All diagnostic info above
- Description of expected vs actual behavior
- Any changes made recently
Prevention
Best Practices
- Test after deployment: Always verify tracking after pushing changes
- Monitor console: Watch for new errors
- Check periodically: Verify script is still present
- Document setup: Record where script was added
Monitoring
Consider setting up:
- Uptime monitoring for your site
- Alerts for JavaScript errors
- Regular testing of affiliate links