Intro to Tracking Affiliate Offer Completions
Introduction
We decided to make a little tutorial after reading a post on Black Hat World where a question regarding tracking IP addresses after offer completion was posed. While we realize that most seasoned affiliates are very aware of the technique we’re going to outline in this post, we hope that our less experienced readers learn something. What you are about to read is one of the most basic ways to really begin analyzing traffic and creating metrics to streamline and optimize your affiliate sales efforts.
Disclaimer
This is not an efficient or elegant way to go about tracking the people who complete your offers. However, if you’re not already currently tracking the leads you’re generating, it is a very simple way to start a process that will help refine your abilities as an affiliate marketer. We’re not going to offer that many code or SQL snippets because we firmly believe that some parts of the game are to be sold, not told. That said, nothing in this article is too complicated for a beginner to figure out.
What You’ll Need
Here are a list of things which you hopefully already have access to, but which are necessary to go forward with the procedure we’re about to discuss
- Shared Hosting (or better)
- PHP4 (or greater)
- MySQL 4 (or better) and the ability to create new DBs
- Text Editor
- FTP client
Getting Started
First off, you’ll want to create a MySQL DB to store and handle the information you’ll begin tracking from here on out. To do that, you’ll probably want to access phpMyAdmin. If you’re unfamiliar with how to use this web application, you should read the manual. You’ll want to create a table and a series of appropriate fields. The number of fields is dependent upon what you want to track. So, for very, very basic tracking you’ll want to create a field to track the user’s subid, the offer ID of the offer the user filled out, the date they filled it out, and their IP address. This is list of fields is very flexible.
Once you’ve created the DB, you’ll want to create a unique ID to begin to track the users that click on your offers. We’ve done this by simply creating a unique identifier with PHP that gets sent by path argument to each URL referrer page like so:
<?php function genKey ($length = 10) { $key = ""; $possible = "0123456789bcdfghjkmnpqrstvwxyz"; $i = 0; while ($i < $length) { $char = substr($possible, mt_rand(0, strlen($possible)-1), 1); if (!strstr($key, $char)) { $key .= $char; $i++; } } return $key; } ?>
You can either put this code into a separate page, include it on your main page, and call the function or just run the entire process on your main page. The output will be a string similar to this: 8g2kbcz0qr
You’ll want to pass this unique identifier onto your referrer pages. You’ll then want to link to your affiliate page with something similar to this:
<a href="http://www.yoursite.com/offer.php?id=<?php echo $key?>" target="_blank">Click here to fill out your offer.</a>
Now you’ll want to figure out how your affiliate network handles subids. Subids are independently assigned path arguments that you can create to send very specific information to your affiliate networks which may then be sent back to you via a universal pingback upon offer completion. There is a fantastic list and small primer on subids located at Subids.com.
Once you’ve figured out how to process subids on your respective network, you’ll want to make sure that the unique ID you created earlier gets passed to the affiliate network. In this example, I’ll use Azoogle’s subid system. So, if you’ve setup a link like I specified earlier, this is the code you’d need to have on http://www.yoursite.com/offer.php:
<?php $sid = trim($_GET['id']); header( "Location: http://x.azjmp.com/%OFFERID%sub=".$sid) ; ?>
%OFFERID% is where you’ll want to place the unique offer ID provided for you by affiliate, which, in this example, is Azoogle.
If you want, you can also begin to track how many users that click your offer links actually complete your offers. To do this, you’ll want to create a record and leave the IP address or offer ID fields blank on the referrer page. This way, you can easily discern between records that have and have not completed offers.
Just like most affiliate networks, Azoogle’s universal pingback tool is very easy to setup. How these tools works is that they send a very basic hit with some path argument attached every time someone completes one of your offers. For this example, a very easy pingback URL to use would be:
http://www.yoursite.com/pingback.php?subid=%%SUB_ID%%&offerid=%%OFFER_ID%%
The %%SUB_ID%% indicates where your SubID will be. Your %%OFFER_ID%% indicates where the unique ID of your offer will be. When a user has completed an offer, http://yoursite.com/pingback.php will receive a “ping” from the affiliate network with all of the information you’ve requested attached via path argument, so you’ll want to be able to read these, right?
The code is very simple:
<?php $subid = trim($_GET['subid']); $oid = trim($_GET['offerid']); list($affid, $sid) = explode("-", $subid); ?>
This will grab each respective argument and store it into a variable. The reason for the explode() is that Azoogle returns each subid with your affiliate ID separated by a dash and then whatever subid you define. So, if you defined 8g2kbcz0qr as the subid and your affiliate ID is 12345 then the resultant argument would be: ?subid=12345-8g2kbcz0qr
Now, since you know that any ping to this page is the result of either a test of yours or an actual completion, you can easily begin to add information like the time and IP address to your database. This can be done by simply assigning the IP address to a variable with the following command:
$ip=$_SERVER['REMOTE_ADDR'];
Once you have the IP address assigned to a variable, adding it to your DB is very simple.
Hopefully everyone who has read this article and was previously unfamiliar with the basics of affiliate tracking now has a better idea of how to go about doing it. As I stated in the beginning, this is by no means the most elegant or efficient way to go about tracking, it’s just a very basic way that works.
Trackbacks & Pingbacks
- Pingback by Introduction to Affiliate Offer Completion Tracking - Black Hat Forum on July 7, 2008 @ 10:15 pm
Excellent post! Defintely got me thinking about a way to implement this…thanks.