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
- Log into your AffRank dashboard
- Click Script Generator from main menu
- 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
| Parameter | Values | Default | Description |
|---|---|---|---|
mode | production, debug | production | Set to debug for console logging |
tracking | enabled, disabled | enabled | Enable/disable click tracking |
delay | 0-5000 | 0 | Delay script execution (ms) |
version | latest, stable | latest | Script 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
- Visit your website
- Press F12 (Developer Tools)
- Go to Console tab
- Look for:
AffRank v1.x loaded successfully
Test Link Insertion
- Add an affiliate link in dashboard
- Visit page with matching keyword
- Check that link is inserted
- Click the link
- Verify click appears in analytics
Monitor Network
- Open Network tab in Dev Tools
- Refresh page
- Look for request to
affrank.io/script/... - Verify response status is 200
Regenerating Your Script
If you need a new script (security refresh, new installation):
- Go to Script Generator
- Click Generate New Script
- Old script becomes invalid (if desired)
- 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
Links Not Inserting
- 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.