Pageview Tracker
The pageview tracker captures when visitors arrive via affiliate links. This is the foundation of Affitor tracking.
What It Does
When someone clicks a partner's affiliate link (https://yoursite.com?ref=PARTNER123), the tracker:
- Detects the
?ref=parameter - Stores
partner_codein a cookie - Generates a unique
customer_code - Sends a click event to Affitor
All subsequent events (signups, purchases) are linked via these cookies.
Installation
Add this script tag to your website's <head> section:
<script
src="https://api.affitor.com/js/affitor-tracker.js"
data-affitor-program-id="YOUR_PROGRAM_ID"
data-affitor-debug="false">
</script>That's it. The script handles everything automatically.
Configuration
| Attribute | Required | Description |
|-----------|----------|-------------|
| src | Yes | Affitor tracker script URL |
| data-affitor-program-id | Yes | Your program ID (from dashboard) |
| data-affitor-debug | No | Set "true" for test mode |
Finding Your Program ID
- Go to your Affitor dashboard
- Navigate to Settings → Integration
- Copy your Program ID
Where to Add the Script
Add the script to every page where affiliate traffic might land.
Recommended: Add to your site's global <head> so it loads on all pages.
HTML Example
<!DOCTYPE html>
<html>
<head>
<title>Your Site</title>
<script
src="https://api.affitor.com/js/affitor-tracker.js"
data-affitor-program-id="YOUR_PROGRAM_ID"
data-affitor-debug="false">
</script>
</head>
<body>
<!-- Your content -->
</body>
</html>Next.js (App Router)
import Script from 'next/script'
export default function RootLayout({ children }) {
return (
<html>
<head>
<Script
src="https://api.affitor.com/js/affitor-tracker.js"
data-affitor-program-id="YOUR_PROGRAM_ID"
data-affitor-debug="false"
strategy="afterInteractive"
/>
</head>
<body>{children}</body>
</html>
)
}React (Vite/CRA)
<!DOCTYPE html>
<html>
<head>
<script
src="https://api.affitor.com/js/affitor-tracker.js"
data-affitor-program-id="YOUR_PROGRAM_ID"
data-affitor-debug="false">
</script>
</head>
<body>
<div id="root"></div>
</body>
</html>Debug Mode
Enable debug mode to see tracking events in your browser console:
<script
src="https://api.affitor.com/js/affitor-tracker.js"
data-affitor-program-id="YOUR_PROGRAM_ID"
data-affitor-debug="true">
</script>With debug mode on, you'll see console logs for:
- Script initialization
- Cookie storage
- Click events sent to Affitor
Remember to set data-affitor-debug="false" before going to production.
Verifying Installation
After adding the script:
- Visit your site with a test referral link:
https://yoursite.com?ref=TEST123 - Open browser DevTools (F12) → Console
- Check for Affitor initialization message
- Go to Application → Cookies → look for
partner_code