Skip to content

Script Generator

The Script Generator is the easiest way to get your AffRank tracking script and install it on your website.

What is the Script Generator?

The Script Generator creates a personalized JavaScript snippet that you add to your website. This script:

  • Loads your affiliate links
  • Automatically inserts them into your content
  • Tracks clicks and conversions
  • Reports data back to your analytics dashboard

Generating Your Script

Step 1: Access Script Generator

  1. Log into your AffRank dashboard
  2. Click Script Generator from main menu
  3. You’ll see your unique User ID and pre-generated script

Step 2: Copy Your Script

<script src="https://affrank.io/script/YOUR_USER_ID.js"></script>
  • Click Copy to Clipboard
  • Script is now ready to paste on your website

Step 3: Choose Installation Method

Option A: Direct HTML

  • Open your website HTML
  • Paste in <head> section
  • Save and deploy

Option B: WordPress

  • Install AffRank WordPress plugin
  • Navigate to Settings → AffRank
  • Paste script code
  • Click Save

Option C: Tag Manager

  • Open Google Tag Manager
  • Create new Custom HTML tag
  • Paste script
  • Set trigger to “All Pages”
  • Publish

Script Customization

Adding Parameters

You can customize script behavior by adding parameters:

<script src="https://affrank.io/script/YOUR_USER_ID.js?mode=production&tracking=enabled"></script>

Available Parameters

ParameterValuesDefaultDescription
modeproduction, debugproductionSet to debug for console logging
trackingenabled, disabledenabledEnable/disable click tracking
delay0-50000Delay script execution (ms)
versionlatest, stablelatestScript version to use

Advanced Configuration

Environment Variables

Configure script behavior via your dashboard:

  • Link Insertion Delay: Time before links are inserted
  • Max Links Per Page: Limit number of links
  • Exclude Pages: Patterns to skip
  • Custom Domains: Track multiple domains

Debug Mode

Enable debug mode to see what’s happening:

<script src="https://affrank.io/script/YOUR_USER_ID.js?mode=debug"></script>

Check browser console (F12) for:

  • Script loading status
  • Number of links loaded
  • Links inserted
  • Click tracking events

Testing Your Script

Verify Installation

  1. Visit your website
  2. Press F12 (Developer Tools)
  3. Go to Console tab
  4. Look for: AffRank v1.x loaded successfully
  1. Add an affiliate link in dashboard
  2. Visit page with matching keyword
  3. Check that link is inserted
  4. Click the link
  5. Verify click appears in analytics

Monitor Network

  1. Open Network tab in Dev Tools
  2. Refresh page
  3. Look for request to affrank.io/script/...
  4. Verify response status is 200

Regenerating Your Script

If you need a new script (security refresh, new installation):

  1. Go to Script Generator
  2. Click Generate New Script
  3. Old script becomes invalid (if desired)
  4. Copy and install new script

Troubleshooting

Script Not Loading

  • Verify User ID is correct
  • Check internet connection
  • Clear browser cache
  • Check console for errors
  • Ensure script URL is accessible
  • Verify links are configured in dashboard
  • Check keywords match your content
  • Allow 5 minutes for sync
  • Verify script is installed correctly
  • Check debug mode console output

Performance Issues

  • Script is optimized (<50KB)
  • Loads asynchronously (non-blocking)
  • Uses efficient DOM manipulation
  • Minimal CPU usage

Best Practices

Do This

  • Install script in <head> section
  • Use same script on all pages
  • Test before going live
  • Monitor analytics regularly
  • Update links periodically

Don’t Do This

  • Install multiple scripts
  • Modify script code manually
  • Remove tracking parameters
  • Use development script in production

FAQ

Q: Can I use multiple scripts? A: No. Only use your official AffRank script. Multiple scripts cause conflicts.

Q: Is the script safe? A: Yes. AffRank scripts are thoroughly tested and use industry-standard security practices.

Q: Does it work with HTTPS? A: Yes. All scripts load over secure HTTPS connections.

Q: Can I customize the script? A: Basic customization via parameters. For advanced changes, contact support.

Next Steps