Tracking Script Installation
The AFFY tracking script enables click tracking on your website. Once installed, every click on an affiliate link is automatically recorded and attributed.
How tracking works
When a visitor arrives via an affiliate link, the tracking script captures the session and stores it in a cookie (30-day attribution window). As the visitor moves through your funnel, each step is tracked:
Visitor clicks an affiliate link. Click is recorded with device and geographic data.
Visitor signs up or starts a trial. The registration is linked to the originating click.
Visitor makes a purchase. Commission is calculated and assigned to the affiliate.
Earnings are recorded and become eligible for payout after approval.
Find your tracking script
Navigate to Program Settings → Marketing & Trackingin your dashboard. You'll find your unique JavaScript snippet and API key there.
Add the script to your site
Copy your snippet from the dashboard and add it to every page of your website, inside the <head> tag. The script loads asynchronously and does not affect page performance.
<head>
<!-- ... other tags ... -->
<script>
(function(w,d,s,a){
w.__affy={apiKey:a};
var sc=d.createElement(s);
sc.async=true;
sc.src='https://cdn.affy.pro/track.js';
d.head.appendChild(sc);
})(window,document,'script','YOUR_API_KEY');
</script>
</head>YOUR_API_KEY with the actual key from your dashboard. The snippet in your dashboard already has it filled in — just copy and paste.Platform-specific guides
Next.js
Add the script to your root layout file so it loads on every page:
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<head>
<script
dangerouslySetInnerHTML={{
__html: `
(function(w,d,s,a){
w.__affy={apiKey:a};
var sc=d.createElement(s);
sc.async=true;
sc.src='https://cdn.affy.pro/track.js';
d.head.appendChild(sc);
})(window,document,'script','YOUR_API_KEY');
`,
}}
/>
</head>
<body>{children}</body>
</html>
)
}WordPress
Add the snippet to your theme's functions.phpfile or use a plugin like "Insert Headers and Footers" to add it sitewide:
function affy_tracking_script() {
?>
<script>
(function(w,d,s,a){
w.__affy={apiKey:a};
var sc=d.createElement(s);
sc.async=true;
sc.src='https://cdn.affy.pro/track.js';
d.head.appendChild(sc);
})(window,document,'script','YOUR_API_KEY');
</script>
<?php
}
add_action('wp_head', 'affy_tracking_script');Track registrations
To link a user registration to an affiliate click, call the registration tracking endpoint when a user signs up on your platform. This connects the new account to the affiliate who referred them.
// Call this after a successful user signup
fetch('https://YOUR_DOMAIN.affy.pro/api/v1/tracking/registration', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'newuser@example.com',
// The click_id is automatically set in localStorage by the tracking script
clickId: localStorage.getItem('affy_click_id'),
}),
})Track conversions (manual)
If you're not using Stripe, Paddle, or Chargebee, you can record conversions manually via the API when a purchase is completed:
// Call this from your server after a successful payment
await fetch('https://YOUR_DOMAIN.affy.pro/api/v1/tracking/conversion', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY',
},
body: JSON.stringify({
email: 'customer@example.com',
amount: 99.00,
currency: 'USD',
transactionId: 'order_12345',
}),
})