Protecting Your Affiliate Marketing Data With Encryption
Affiliate Marketing, Programming September 30th, 2007You probably know that your keyword list and testing results are the most valuable assets in your PPC marketing campaign. Without the right keywords and the best converting landing pages for each of them, you are the same as anyone else in your niche. But did you know that your merchants are probably looking at your tracking data and may be using it for their own in-house PPC marketing? Here is an *easy* (or maybe not) way to make sure all of your data is protected.
How It Works
All you need to do is come up with a simple encryption system for your campaign, ad group, keyword, and testing data. This must, however, be done with database programming (such as PHP/MySQL) because trying to keep track of this stuff manually would be impossible.
Basically, we are just taking each tracking value, giving it a numerical ID, and converting that ID into a compressed alphanumeric string. This is similar to using numbers, but greatly expands the amount of possibilities. If we have a tracking ID that is three digits long and uses “0-9″ we would be able to store “999″ different values. Conversely, if we use “0-9″, “a-z”, and “A-Z” we would be able to store 238,327 unique values (62*62*62-1). Think you might need more than that many values? Adding a fourth character would increase the total to almost 15 million!
So what you can do here is create a string of all these unique IDs. An example data string could be “bo-29Di-w9j-w2BI”. This would give you 4 different variables with plenty of unique possibilities for each of them. And no one would ever know what that information means.
Now, to implement a system like this, you will need some programming that encrypts and decrypts your values on the fly. You would ideally want it to take an entire CSV report and organize all of the data for you. Depending on the level of protection you want, you could encrypt your variables in your PPC campaigns (hiding your data from everyone) or you can encrypt them on your landing page (hiding your data from the merchants/networks only).
Assigning Numerical IDs
The first step is to assign each of your variables a numerical ID that will be stored in your database. The easiest way to do this is to just store the variable and let the database software automatically assign an incremental ID. There are many ways you could do this. You could have one table that holds “records” (campaign, ad group, keyword, and id), you could have multiple tables that hold variable, or you could have one table that holds keywords.
I think the second approach is the best and most flexible. So, I will create one table for each type of data that I want to track. There will be a table of campaigns, a table of ad groups, a table of keywords, and tables for any miscellaneous data. These tables will only include two fields each, a data field and an ID field. Here is an example of what a “keyword” table might look like:

How you get those values into your database is up to you. You could create the entries “on-the-fly” or you could pre-populate them.
Converting Numeric IDs to Alphanumeric IDs
Now that we have all of our tracking information stored in a database, we can reference their IDs and no one will know what they mean. However, instead of including extremely long numerical information, we will convert them to an alphanumeric system to shorted everything up. Here is the part of my script that turns any number into a base-62 string:
<?php
$num = 7029;
$base = 62;
$chars = ‘0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;
while($num >= $base) {
$r = $num%$base;
$result = $chars[$r].$result;
$num = $num/$base;
}
$result = $chars[$num].$result;
?>
This code isn’t really a matter of programming, it is more of a math problem. What it does is build the number from right to left by continually getting the remainder and converting that to one of the 62 available characters until there are no more remainders left.
Converting Alphanumeric IDs Back to Numeric IDs
After you have passed your encrypted tracking variables to the merchant, and they have been tracked in your affiliate account, you need a way to translate them back into readable information. Here is the part of my script that turns your base-62 string back into a number:
<?php
$id = ‘1Pn’;
$base = 62;
$chars = ‘0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ’;
for ($i=0; $i<strlen($id); $i++) {
$value = strpos($chars, $id[$i]);
$num = $value * pow($base, strlen($id)-($i+1));
$final += $num;
}
print $final;
?>
This code works in reverse of the previous code. It takes each “character” and converts it to is respective value by multiplying it by it placement and then adds them all together. In standard numbers this is equal to getting 672 out of 600+70+2… it just looks more complex because it is base-62 instead of base-10.
Why Go Through All This Trouble?
There are a couple reasons why would you want to implement an encryption system like this into your tracking efforts. The most obvious benefit, which was already mentioned, is that it protects your valuable data from prying eyes. No one, unless they have access to your database and translation scripts, will know what the information means.
Another benefit is the ability to easily track tons of variables. It might be easier to use explicit variable names in your URLs when you are only tracking a couple variables, but what if you wanted to track 10-15 different things such as keywords, colors, headlines, graphics, layouts, and more?
Here are some more articles that I wrote on testing and tracking. Have a look at them to further understand the implementation and importance.

September 30th, 2007 at 2:26 pm
Whoa Derek! This is some advance stuff
I will just stick to using Paypal for now
September 30th, 2007 at 10:20 pm
Derek,
Interesting post.
This refers to googlecash strategy — direct linking correct ?
I am using a different strategy right now. I am redirecting everything through a basic tracking software that I made based on slimstat. This tells me the exact keyword they typed in but to the merchant it should appear that they are coming from my tracking website ..
Google conversion tracking should work with this as well ..
Have you considered this method ? Does this make sense ?
It has helped me build a big list of negative matches and improved my CTR in one particular case.
September 30th, 2007 at 10:58 pm
Warrior – this doesn’t have anything to do with PayPal
Fields – it can be used with direct linking or landing pages. Anytime you are passing data to the merchant (such as subids) or display data in your URL strings, there is the potential for other people to access it. By encrypting it with a system such as this, there is no way anyone can make sense of it.
October 1st, 2007 at 2:14 pm
October 1st, 2007 at 6:12 pm
I thought that a merchant would only see that you’ve sent a user through your site (landing page) even if user came from ppc. How is it possible for a merchant to track ppc data if you’re using your site?
October 1st, 2007 at 6:20 pm
Phil – If you are sending tracking data to the merchant, they can see it. This information is passed in CJ by adding “sid=” to the end of your link and in AzoogleAds by adding “sub=” to the end of your link. All affiliate networks have this function and many affilaites pass their keyword data through it.
October 7th, 2007 at 4:29 am
[...] Protecting Your Affiliate Marketing Data With Encryption (Derek Beau) [...]
October 13th, 2007 at 1:16 am
Taking this one step further. if you want to do a little click tracking direct to a db then you can record all the data of the click besides price, but then go back and match later from reports.
Basically the click would get recorded as a row inside of the db then you’d have the link or bounce to the affiliate link replace that row number with the subid. Then pull your conversion reports from your affiliate company. Match the conversion subid’s with the row’s and you have nice click tracking for all your data.
I did a full tutorial on my site if anyone is interested in finding more about this. Some nice stuff you can find with click tracking is
1. fraud, as you track ip,source,referer. For example on yahoo I got a ton of clicks from some domainer site. all 15 minutes apart. for about 2 days. Of course not one converted.
2. see what words are converting.
3. track referers so you can parse the referer strings and get the actual queriest people used out of them. To add to your keyword list.
4. When you get more advanced you can dump in your click data by tracking click id’s and then get an exact ROI calc and adjust bids accordingly.
Those are just a few thing it can help you with. Easiest thing to do is test a nice bounce page. As typically you don’t want the affiliate company or advertiser tracking your referers ( yes they do that ) and keywords. Make sure you meta refresh them to the destination as this will most of the time strip out all the referers data. Well you get the point
http://www.oooff.com if you want to take a look at the tutorial. I don’t run ads on my site as I don’t generate income from it. It’s just there to hopefully help people makes some more money
Success,
Smaxor
November 2nd, 2007 at 1:09 pm
ONLINE – DRUGSTORE!
PRICES of ALL MEDICINES!
FIND THAT NECESSARY…
VIAGRA, CIALIS, PHENTERMINE, SOMA… and other pills!
Welcome please: pills-prices.blogspot.com
NEW INFORMATION ABOUT PAYDAY LOANS!
Welcome please: payday-d-loans.blogspot.com
GOOD LUCK!
March 17th, 2009 at 9:52 pm
I found your blog on google and read a few of your other posts. I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future. Thank you
September 5th, 2009 at 4:32 pm
it is interesting topic. how could you pass the this id cross pages ? do it affect you SEO ?
November 14th, 2009 at 2:46 am
I believe there is a limit or either a bug in this code. Is there a limit to the actual length of the number you encrypt? Cause when I feed it the number 4354467891 it decrypts to 4354467887. Using a number like 1234567890 works perfectly, same number of digits, just not as high a value. I know you could encypt smaller numbers and construct a sting, but I just trying to use one big number, and after decrypting, then split it into its sub-parts as needed, but that big 10 digit number (4354467891) does not decode properly. Any ideas? Thanks.