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:

  1. Detects the ?ref= parameter
  2. Stores partner_code in a cookie
  3. Generates a unique customer_code
  4. 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

  1. Go to your Affitor dashboard
  2. Navigate to Settings → Integration
  3. 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

index.html
<!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)

app/layout.tsx
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)

index.html
<!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:

  1. Visit your site with a test referral link: https://yoursite.com?ref=TEST123
  2. Open browser DevTools (F12) → Console
  3. Check for Affitor initialization message
  4. Go to Application → Cookies → look for partner_code

Next Steps