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
affiliatebaseortrack.js - 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/@relay-capital/affiliatebase-tracking@1.0.9/dist/track.min.js"
data-account-id="YOUR_ACCOUNT_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 “track.js”
- 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 is in a shared layout or site-wide custom-code area, ideally before
</body> - Clear any caching (CDN, browser, CMS cache)
- Verify the page uses the correct template
Issue: Wrong Account ID
Symptom: Script loads but no tracking occurs.
Solutions:
- Go to AffiliateBase dashboard
- Copy your account ID from setup
- Update
data-account-idin your script - Deploy changes
<!-- Verify this matches your dashboard -->
<script ... data-account-id="correct-account-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 cdn.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:
- Keep the script in the shared layout so it loads before the visitor starts checkout
- Wait for script to initialize:
affiliatebase('ready', () => {
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 or Local App Testing
Symptom: Browser checks work locally, but final Stripe attribution does not appear in production.
Explanation: Local checks are useful for confirming the script, form field, or checkout link receives a referral value. The final Stripe checkout proof should run from a reachable staging or production page.
Solutions:
- For local app checks, use
/track.js,data-api-url="http://localhost:3000", anddata-debug="true". - Confirm
window.AffiliateBase.referralis present after opening a test affiliate link. - Confirm the checkout form or Stripe link receives the referral value.
- Run the final Stripe Checkout test from a deployed page.
Verification Steps
Step 1: Confirm Script Loads
In console, run:
typeof window.affiliatebase
// Should return "function"
Step 2: Check Initialization
In console, run:
Boolean(window.AffiliateBase)
// Should return true after the script loads
If you enabled data-debug="true", look for AffiliateBase debug messages in the console.
Step 3: Test Referral Capture
- Visit:
https://yoursite.com?via=test - In console, run:
console.log(window.AffiliateBase?.referral || window.affiliatebase_referral);
// Should output a generated referral ID after a valid affiliate link click
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/track - Should return 200 status
Platform-Specific Issues
WordPress
- Check the theme footer or global custom-code area 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, usually in the footer code area
- Publish changes
- Clear Webflow CDN cache
Shopify
- Add to theme.liquid before
</body>or through the theme’s global custom code - 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 account 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