How To Use Coupon Codes to To Track Referral Partner Sales in Infusionsoft

On occasion Infusionsoft users would like to use promo codes to track Referral Partner sales.

In other words, each Referral Partner is given a unique promo code. When their contacts use the promo code at checkout, the sale is tracked back to that Referral Partner for commissions.

The problem is, Infusionsoft doesn’t do that out of the box.

But, there’s always a way.

First, we need to understand how Referral Partner tracking in Infusionsoft works. Each Referral Partner has their own “Affiliate Code”. This code is their username when they’re logging into the Referral Partner Resource Center. It’s also used in their standard tracking links to identify which partner the click or sale belongs to:

The AFFCODE portion of the tracking link is replaced with the Referral Partners actual code.

When a contact clicks this link, they are cookied with that Referral Partner’s Id. That cookie is read when the contact ops in or purchases. The cookie being set before the sale is the key.

So, how can we leverage this for promo codes?

First, you’ll need to create a promo code for each of your Referral Partners. This isn’t a good idea if you have hundreds of Referral Partners for which you want to do this. Choose the top 10, they’re producing 90% of the sales anyways. So, create a promotion and a coupon code for each of them. The coupon code must match their “affiliate code”.

Next, create a page that the contact will visit before going to the order form. On this page, you’ll have a form where they enter their “coupon code”. This doesn’t need to be an Infusionsoft web form. In fact, here’s the code for what you need:

<script type="text/javascript">
    function getAffLink() {
        var code = document.getElementById("code").value;
        var url = "" + code + "/?code=" + code;

<form name="affCodeRedirect">
    Coupon Code: 
    <input id="code" name="code" type="text" /> 
    <input type="submit" value="Next" />

In this case, when the customer enters the “coupon code”, which is really the Referral Partner code, the page will redirect through the Referral Partner’s tracking link.

Note: Be sure to change APPNAME to your Infusionsoft account appname. And replace REDIRECT with the actual redirect code you set up with you create a new tracking link.

That tracking link must redirect to an order form.

On the order form, you’ll need to add the Javascript below to capture the Referral Partner code being passed in the URL and apply it as the promo code, thus achieving whatever discount or promotion you’ve set up for your Referral Partner.

Here’s the Javascript code to add to one of the HTML areas in your order form:

<script type="text/javascript">
    jQuery(document).ready(function() {
 	function getUrlVar(key){
 		var result = new RegExp(key + "=([^&]*)", "i").exec(; 
 		return result && result[1] || ""; 

That code will get the Referral Partner code being pass from what the contact entered into the form and automatically apply it as the promo code in the order form.

And, you’re all set.