Affiliate Links

Affiliates help generate revenue by referring customers to your business. WHMCS includes a comprehensive affiliate system with support for one-time and recurring commissions, either in percentages or fixed values. It also includes payout delays, minimum withdrawal limits, and live statistics and information for affiliates in the Client Area.

Before you can use the affiliate system, you must:

  • Configure the settings in the Affiliates tab at Configuration () > System Settings > General Settings.
  • Activate affiliate status in the client’s profile’s Summary tab.
For more information, see Affiliate System.

WHMCS generates a unique code for each affiliate to use on their website. For example:

https://www.example.com/aff.php?aff=001

Affiliates can obtain their unique link via the Client Area by logging in and clicking Affiliates in the main menu.

When a visitor follows an affiliate link, the system will redirect them to the URL that you specified for Domain in the General tab at Configuration () > System Settings > General Settings and will save a cookie in their browser. If the visitor places an order for a product or service with the cookie present, the affiliate will earn a commission.

By default, the cookie persists for three months.

Affiliate Linking Code

You can specify affiliate link code in the Affiliates tab at Configuration () > System Settings > General Settings. For example:

<a href="[AffiliateLinkCode]"><img src="http://www.example.com/banners/468x60banner.gif" width="468" height="60" border="0"></a><br>
<(a href="[AffiliateLinkCode]")><(img src="http://www.example.com/banners/468x60banner.gif" width="468" height="60" border="0")><(/a)><br><br>
<a href="[AffiliateLinkCode]"><img src="http://www.example.com/banners/120x60banner.gif" width="120" height="60" border="0"></a><br>
<(a href="[AffiliateLinkCode]")><(img src="http://www.example.com/banners/120x60banner.gif" width="120" height="60" border="0")><(/a)><br><br>

If you enter this code, it will display the image preview of the banner first and then the code below it for the affiliate to use. <( and )> are parts of a special syntax that you must use to ensure that the code does not execute as HTML. WHMCS modifies this during display to cause it to appear as normal HTML. You can add advanced link code directly to the affiliates.tpl template file in your active template folder using the {$referrallink} template field wherever you want to include the affiliate’s unique referral URL.

For more information about linking to WHMCS, see Linking to WHMCS.

Linking to a Product Group

You can link directly to the order form for a specific product group. To do this, append &gid=x to the end of [AffiliateLinkCode], where x is the product group ID. For example:

<a href="[AffiliateLinkCode]&gid=2"><img src="http://www.example.com/banners/468x60banner.gif" width="468" height="60" border="0"></a><br>
<(a href="[AffiliateLinkCode]&gid=2")><(img src=http://www.example.com/banners/468x60banner.gif" width="468" height="60" border="0")><(/a)>

Linking to a Product

You can link directly to the order form for a specific product. To do this, append &pid=x to the end of [AffiliateLinkCode], where x is the product ID. For example:

<a href="[AffiliateLinkCode]&pid=2"><img src="http://www.example.com/banners/468x60banner.gif" width="468" height="60" border="0"></a><br>
<(a href="[AffiliateLinkCode]&pid=2")><(img src=http://www.example.com/banners/468x60banner.gif" width="468" height="60" border="0")><(/a)>

Linking to the Cart

You can link directly to the cart. To do this, append &gocart=true to the end of [AffiliateLinkCode]. For example:

<a href="[AffiliateLinkCode]&gocart=true"><img src="http://www.example.com/banners/468x60banner.gif" width="468" height="60" border="0"></a><br>
<(a href="[AffiliateLinkCode]&gocart=true")><(img src=http://www.example.com/banners/468x60banner.gif" width="468" height="60" border="0")><(/a)>

Linking to the Registration Form

You can link directly to the registration form. To do this, append ®ister=true to the end of [AffiliateLinkCode]. For example:

<a href="[AffiliateLinkCode]&register=true"><img src="http://www.example.com/banners/468x60banner.gif" width="468" height="60" border="0"></a><br>
<(a href="[AffiliateLinkCode]&register=true")><(img src=http://www.example.com/banners/468x60banner.gif" width="468" height="60" border="0")><(/a)>

Affiliate Cookies

The affiliate link cookie lasts for three months on the user’s computer by default. You can change the cookie duration by editing the aff.php file.

Line 24 controls the creation of the cookie and how long it lasts:

Cookie::set('AffiliateID',$aff,'3m');

When editing this line, only alter the final argument (3m).

The final argument defines the lifetime of the cookie using PHP timestamps. For convenience, we offer a helper when defining months. When you require months, specify the number of months and append m (as in the example above).

The following examples are commonly-used lifetimes:

LifetimeExample File Line
One dayCookie::set('AffiliateID', $aff, time() + (24*60*60));
Seven daysCookie::set('AffiliateID', $aff, time() + (7*24*60*60));
14 daysCookie::set('AffiliateID', $aff, time() + (14*24*60*60));
One monthCookie::set('AffiliateID', $aff, '1m');

Last modified: October 29, 2024