Getting Started

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:

1
Click

Visitor clicks an affiliate link. Click is recorded with device and geographic data.

2
Lead

Visitor signs up or starts a trial. The registration is linked to the originating click.

3
Conversion

Visitor makes a purchase. Commission is calculated and assigned to the affiliate.

4
Commission

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.

Your tracking snippet is unique to your account. Do not share it publicly — it contains your API key.

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.

Basic HTML installation
html
<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>
Replace 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:

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

functions.php
php
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.

Track a registration (client-side)
javascript
// 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:

Track a conversion (server-side)
javascript
// 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',
  }),
})
If you've connected Stripe, Paddle, or Chargebee, conversions are tracked automatically via webhooks — you don't need to call this endpoint manually.

Verify installation

Create a test affiliate link

Go to your affiliate portal (your subdomain) and log in as an affiliate. Copy one of the tracking links from the dashboard.

Click the link

Open the tracking link in a browser. You should be redirected to your website.

Check the referrals page

In your client dashboard, go to the Customers section. A new click entry should appear within a few seconds.