Skip to main content

Script Not Loading

Troubleshoot issues with the AffiliateBase tracking script

Table of Contents

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

  1. Right-click on your page → View Page Source
  2. Search for affiliatebase or track.js
  3. 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

  1. Open Developer Tools (F12 or right-click → Inspect)
  2. Go to the Console tab
  3. Look for red error messages
  4. Search for messages containing “affiliatebase”

Check Network Tab

  1. Open Developer Tools
  2. Go to Network tab
  3. Filter by “affiliatebase” or “track.js”
  4. Look for the script request
  5. Check status (should be 200)

Common Issues & Solutions

Issue: Script Not in HTML

Symptom: Script tags not found in page source.

Solutions:

  1. Verify you added the script to your template/theme
  2. Check it is in a shared layout or site-wide custom-code area, ideally before </body>
  3. Clear any caching (CDN, browser, CMS cache)
  4. Verify the page uses the correct template

Issue: Wrong Account ID

Symptom: Script loads but no tracking occurs.

Solutions:

  1. Go to AffiliateBase dashboard
  2. Copy your account ID from setup
  3. Update data-account-id in your script
  4. 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:

  1. Disable ad blocker temporarily to test
  2. Check if your ad blocker has strict rules
  3. Test in incognito/private mode
  4. 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:

  1. CORS errors usually indicate a configuration issue
  2. Verify you’re loading from the official CDN
  3. Check your server isn’t proxying incorrectly
  4. Ensure no conflicting headers

Issue: Script Loading Too Late

Symptom: Script loads but window.affiliatebase_referral is undefined when accessed.

Solutions:

  1. Keep the script in the shared layout so it loads before the visitor starts checkout
  2. Wait for script to initialize:
affiliatebase('ready', () => {
  console.log('Referral:', window.affiliatebase_referral);
});
  1. 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:

  1. Search your code for multiple script inclusions
  2. Check theme/plugin conflicts
  3. 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:

  1. For local app checks, use /track.js, data-api-url="http://localhost:3000", and data-debug="true".
  2. Confirm window.AffiliateBase.referral is present after opening a test affiliate link.
  3. Confirm the checkout form or Stripe link receives the referral value.
  4. 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

  1. Visit: https://yoursite.com?via=test
  2. 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

  1. Go to Developer Tools → Application → Cookies
  2. Look for ab_referral cookie
  3. Should contain referral data

Step 5: Check Network Request

  1. Visit with ?via=test parameter
  2. Look for request to /api/track
  3. 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/script component for proper loading
  • Add to _app.js or _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:

  1. Screenshot of console errors
  2. Screenshot of network tab (filtered to affiliatebase)
  3. Your website URL
  4. Your account ID
  5. Browser and version
  6. 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

  1. Test after deployment: Always verify tracking after pushing changes
  2. Monitor console: Watch for new errors
  3. Check periodically: Verify script is still present
  4. 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

Next steps