How to track and identify individuals through affiliate links

Incentives don’t just involve paying people to click links. One of the coolest things you can do to improve conversions is to offer a free bonus to people who purchase a product through your affiliate link. It’s easy to give away stuff if you’re selling your own product, but a little trickier if you’re promoting someone else’s.

If you want to offer an incentive of any kind to people who do this (say, a free ebook if they join a survey site) then you’ll need to identify exactly who has completed a transaction in order to reward them.

You can track individual clicks and purchases using a Sub-ID. This is a code attached to the end of an affiliate link and for it to work it needs to be unique for each visitor. Once your visitors make a purchase using their own SID it will show up in your affiliate network’s account stats and you can then take the appropriate action.

You can use a Sub-ID with both Commission Junction and Clickbank quite easily. The following screenshots show how:

It’s fairly trivial to set up a unique SID. You can use a simple script to generate a random number each time someone clicks the link. This isn’t very useful however since you need to be able to relate the SID code to a particular customer if you want to reward them. There’s no point in it being anonymous.

The solution is to give the customer an opportunity to identify themselves to you, e.g. get them to create their own SID and at the same time have them tell you who they are.

Setting something like this up is also pretty easy, but it gets a little more complicated when you consider the checks and balances required for it to actually work properly. For instance, you’ll need to make sure that two different customers can’t create the same SID, so you’ll have to save a record of previous customers to check against.

So lets get into the mechanics of how to create such a system.

We need the user to give us at least two pieces of information: Their own unique SID (we’ll tell them to create a ‘username’) and their email address (as a way for you to contact them and deliver their incentive).

We can create a simple html form in php for this:

<?php
echo ”
<form method=\”post\” action=\”$PHP_SELF\”>
<label>Username</label><br/><input name=\”name\”/><br/>
<label>Email</label><br/><input name=\”email\”/><br/>
<input type=\”submit\” name=\”addname\” value=\”Submit\”/>
</form>”;
?>

We could save our users’ data to a database but there’s no real need to get complicated so we’ll save it to a text file instead. We’ll have each user’s data on one line separated by commas:

bob,bob@email.com
jeff,jeff@email.com

Side Note: You don’t want anyone viewing your data file and discovering the email addresses of all your clients! Keep it private by adding the following lines to your .htaccess file (assuming your data file is called ’something.inc’):

<Files ~ “\.inc$”>
Order allow,deny
Deny from all
</Files>

Now we can check the form submission data against the data in the file from previous submissions to prevent duplicates. So first we read the file and split it into lines and fields and store the values in an array:

<?php
$lines = explode(”\n”,$theFileData);

foreach ($lines as $i => $value) {
$line[$i] = explode(’,', $lines[$i]);
$names[$i] = $line[$i][0];
$emailaddr[$i] = $line[$i][1];
}
?>

Now we grab the data the user submitted to our form and loop through the saved file data to see if it clashes:

<?php
$username = $_POST[’name’];
$useremail = $_POST[’email’];

foreach ($names as $n => $value) {
if ($username == $names[$n]){
die(”Username already used! Be more creative and <a href=$PHP_SELF>choose another</a>.”);
}
}
?>

If the username is unique then we can proceed. First we’ll add it to our saved file:

<?php
// Construct another line of data to add to our file to check against future submissions
$stringData = “\n$username,$useremail”;
// Open the file in ‘append’ mode to add the data
$fh = fopen($fileName, ‘a’) or die(”Can’t open file”);
fwrite($fh, $stringData);
fclose($fh);
?>

Now we can add the username as a parameter to the end of your affiliate url. The following example works with Clickbank where your standard affiliate link (referred to here as ‘$desturl’) is in the format: ‘http://yourname.merchant.hop.clickbank.net/’

<?php
$newdest = $desturl . “?tid=” . $username;
?>

The affiliate link then becomes ‘http://yourname.merchant.hop.clickbank.net/?tid=username’

All we have to do now is display the modified url to the user (echo $newdest;) and get the script to tell us we’ve just had a submission. We could create a fancy admin panel where we can login and view submissions, but shit why not just email ourselves with the details?

<?php
$subject = “$username, $useremail just registered”;
$body = “User $username registered using the Sid-Sender form.\r\nTheir email address is: $useremail\r\nLink generated was: $newdest”;
$headers = “From: $useremail\r\n” .
“X-Mailer: php”;
if (mail($youremail, $subject, $body, $headers)) {
echo(”<p>Message successfully sent!</p>”);
} else {
echo(”<p>Message delivery failed…</p>”);
}
?>

And that’s pretty much it. I haven’t found a satisfactory automatic method of checking to see if your users have actually purchased after following their unique links, so once you’ve received their email you’ll have to check your commission stats yourself in a couple of hours and take action once they’ve been reported. If your users aren’t in a hurry you could do it in batches a couple of times a day.

If you like the idea of this type of tool but don’t want to bother with coding it up, I have just the thing for you:

SID-SENDER!

I’ve created my own tool for tracking users based on the script exerpts in this post. The tool works with both Clickbank and Commission Junction links, gives the option of using a Captcha to prevent bots using the form, and lets you limit the number of signups.

This script ain’t free though - It’ll cost you a whopping five bucks. If you think it’s worth it, click here to get your copy.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Footer