Pageview Tracker
The pageview tracker captures when visitors arrive via affiliate links. This is the foundation of Affitor tracking.
What It Does
Section titled “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
Section titled “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
Section titled “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
Section titled “Finding Your Program ID”- Go to your Affitor dashboard
- Navigate to Settings → Integration
- Copy your Program ID
Where to Add the Script
Section titled “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.
Examples:
Section titled “Examples:”<!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 (Pages Router):
Section titled “Next.js (Pages Router):”import { Html, Head, Main, NextScript } from 'next/document'
export default function Document() { return ( <Html> <Head> <script src="https://api.affitor.com/js/affitor-tracker.js" data-affitor-program-id="YOUR_PROGRAM_ID" data-affitor-debug="false" /> </Head> <body> <Main /> <NextScript /> </body> </Html> )}Next.js (App Router):
Section titled “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 (Create React App):
Section titled “React (Create React App):”<!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>How Affiliate Links Work
Section titled “How Affiliate Links Work”Partners receive links in this format:
https://yoursite.com?ref=PARTNER123Or with a landing page:
https://yoursite.com/pricing?ref=PARTNER123The tracker detects any URL with ?ref= and captures the partner code.
Short Links
Section titled “Short Links”Partners can also use Affitor short links:
https://affitor.com/r/abc123These redirect to your site with the ?ref= parameter automatically added.
Verifying Installation
Section titled “Verifying Installation”Test Mode
Section titled “Test 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>Then:
- Open your browser’s Developer Tools (F12)
- Go to the Console tab
- Visit your site with
?ref=TEST123 - Look for Affitor debug messages
Check Cookies
Section titled “Check Cookies”- Open Developer Tools → Application → Cookies
- Look for
partner_codeandcustomer_code - Values should be set after visiting with
?ref=
Dashboard Verification
Section titled “Dashboard Verification”- Visit your site with a test referral link
- Go to Affitor dashboard → Integration Status
- Pageview tracker should show “Connected”
Troubleshooting
Section titled “Troubleshooting”Script Not Loading
Section titled “Script Not Loading”Symptoms: No cookies set, no console messages in debug mode
Check:
- Script URL is correct
- No Content Security Policy blocking the script
- Script is in
<head>, not<body>
Cookies Not Set
Section titled “Cookies Not Set”Symptoms: Script loads but cookies are missing
Check:
- URL has
?ref=parameter - Site is served over HTTPS (required for secure cookies)
- No browser extensions blocking cookies
Events Not Appearing in Dashboard
Section titled “Events Not Appearing in Dashboard”Symptoms: Cookies set but no events in Affitor
Check:
- Program ID is correct
- Backend API is reachable
- Check browser Network tab for failed requests