This guide is for merchants and developers whose AffiliateBase tracking script (track.js) is missing, blocked, or loads without creating browser referral state. Start with the page source and the Network tab. Then check the account ID, content security policy, timing, and your platform.
Quick diagnosis
Check that the script is present
- Right-click your page -> View Page Source
- Search for
affiliatebaseortrack.js - Confirm the script tag is there
Expected code:
<script
async
src="https://app.affiliatebase.io/track.js"
data-account-id="YOUR_ACCOUNT_ID">
</script>Check the 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 the Network tab
- Open Developer Tools
- Go to the Network tab
- Filter by “affiliatebase” or “track.js”
- Look for the script request
- Check the status (it should be 200)
Common Issues & Solutions
Issue: Script not in HTML
Symptom: The script tag isn’t in the page source.
Solutions:
- Confirm you added the script to your template or theme
- Check that it’s in a shared layout or site-wide custom-code area, ideally before
</body> - Clear any caches (CDN, browser, CMS)
- Confirm the page uses the right template
Issue: Wrong account ID
Symptom: The script loads, but nothing is tracked.
Solutions:
- In AffiliateBase, open Setup step 4 (Choose your checkout) and choose your checkout path to see Add the tracking script
- Choose Copy script. The copied snippet contains your account ID
- Replace the
data-account-idvalue in the script on your site - Deploy the change
<!-- Verify this matches the snippet in Setup step 4 -->
<script ... data-account-id="correct-account-id"></script>Issue: Script blocked by an ad blocker
Symptom: The network request is blocked or fails.
Solutions:
- Turn off the ad blocker temporarily to test
- Check whether your ad blocker uses strict rules
- Test in an incognito or private window
Issue: Content Security Policy (CSP) Blocking
Symptom: The console shows a CSP violation error.
Error example:
Refused to load script from 'https://app.affiliatebase.io/track.js'
because it violates Content-Security-PolicySolutions:
Allow app.affiliatebase.io in your script-src and connect-src policies:
Content-Security-Policy: script-src 'self' https://app.affiliatebase.io; connect-src 'self' https://app.affiliatebase.io;Or in a meta tag:
<meta http-equiv="Content-Security-Policy"
content="script-src 'self' https://app.affiliatebase.io; connect-src 'self' https://app.affiliatebase.io;">Issue: CORS error
Symptom: The console shows a CORS error.
Cause: CORS errors usually point to a configuration problem.
Solutions:
- Confirm you’re loading from
https://app.affiliatebase.io/track.js - Check that your server isn’t proxying the script incorrectly
- Remove any conflicting headers
Issue: Script loads too late
Symptom: The script loads, but window.affiliatebase_referral is undefined when your code reads it.
Solutions:
- Keep the script in the shared layout so it loads before the visitor starts checkout
- For advanced code that calls
affiliatebase(...)before the remote script loads, add the command-queue preloader from the Tracking Script Reference - Wait for the script to initialize:
affiliatebase('ready', () => {
console.log('Referral:', window.affiliatebase_referral);
});- Or check before reading it:
// Check if ready
if (window.AffiliateBase) {
console.log(window.affiliatebase_referral);
} else {
// Script not loaded yet
}Issue: Multiple script instances
Symptom: Unexpected behavior or duplicate tracking.
Solutions:
- Search your code for more than one copy of the script
- Check for theme or plugin conflicts
- Load the script only once per page
Issue: Localhost or local app testing
Symptom: Browser checks work locally, but final Stripe attribution doesn’t appear in production.
Cause: Local checks confirm that the script, form field, or checkout link receives a referral value. The final Stripe checkout test 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 the 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 loadsIf you enabled data-debug="true", look for AffiliateBase debug messages in the console.
Step 3: Test referral capture
- Visit with a real affiliate link:
https://yoursite.com?via=YOUR_TOKEN - In console, run:
console.log(window.AffiliateBase?.referral || window.affiliatebase_referral);
// Should output a generated referral ID after a valid affiliate link clickStep 4: Check cookies
- Go to Developer Tools -> Application -> Cookies
- Look for a cookie starting with
ab_referral(for exampleab_referral_<account_id>) - Confirm it contains referral data
Step 5: Check the network request
- Visit with a real affiliate link (
?via=YOUR_TOKEN) - Look for a request to
/api/track - Confirm it returns a 200 status
Platform-specific issues
WordPress
- Check that the theme footer or global custom-code area has the script
- Confirm 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 the site again
Shopify
- Add to theme.liquid before
</body>or through the theme’s global custom code - Or use Google Tag Manager
- Save the theme, then clear your CDN cache if you use one
React/Next.js
- Use the
next/scriptcomponent to load it - Add to
_app.jsor_document.js - Confirm the build process isn’t removing it
Single-page applications
- Make sure the script loads on the initial page load
- The script persists across client-side navigation
- You don’t need to reinitialize it on route changes
Still not working?
Gather diagnostic info
Before contacting support, collect:
- A screenshot of console errors
- A screenshot of the Network tab (filtered to affiliatebase)
- Your website URL
- Your account ID
- Browser and version
- Steps to reproduce
Contact support
Email support@affiliatebase.io with:
- All diagnostic info above
- What you expected and what happened
- Any recent changes
Prevention
Best practices
- Test after deployment: Verify tracking every time you push changes
- Monitor the console: Watch for new errors
- Check periodically: Confirm the script is still present
- Document setup: Record where you added the script
Monitoring
Consider:
- Uptime monitoring for your site
- Alerts for JavaScript errors
- Regular testing of affiliate links