Redirecting direct linking affiliate URLs with PHP
Yesterday I was banging my head against the wall trying to figure out how to do a PHP redirect from my PPC ads to my affiliate links, while still passing the keyword for conversion tracking.
Why did I bother? Because I was promoting a merchant from XY7 which doesn't allow affiliates to show their URL on PPC ads. Since I didn't want to create a landing page, I figured I would snag a domain name and just redirect the offer through it. I could then use my new domain's URL as the display/destination URL for my Yahoo ads. Even though I have a love/hate relationship with Yahoo, I didn't bother doing this on AdWords, since they frown upon affiliate redirects.
I thought this would be relatively easy, say, do a google search and get the code I need. Wrong! The code I needed was nowhere to be found. Even though I used to know some programming from my unfinished IT career, I had never coded PHP. So I had to use the old trial and error to come up with the damn code. After some 2-4 hours I finally got something that worked. So here it is:
<?php
$keyword = $_GET['ovkey'];
$URL = "http://redirect.tracking202.com/dl/XXXXXXX?t202kw=".$keyword;
header("Location: $URL") ;
?>
This is using Tracking202, but it should work with any tracking solution that appends keywords in some way. The part after the ? sign should include the keyword variable name (in Tracking202 it's 't202kw'). The 'ovkey' on the GET method is used to get the keyword from Yahoo's tracking system (I think it stands for OVerture KEY).
In order for this to work you need to have tracking enabled on your Yahoo Search Marketing account. Yahoo appends the keyword (the 'ovkey') automatically to the end of the URL, which the code above grabs and appends into your tracking URL. So on your Yahoo ads you would just put the URL for the page holding your PHP redirect into the destination/display URL fields.
This code should also work for Adwords or MSN. In Adwords you would have to use dinamic keyword insertion to grab the keyword and pass it to your redirect page. To do that, make your destination URL like this on Adwords:
http://www.yourtrackingpage.com/trackingpagename.php?kw={Keyword:no keyword}
You would also have to change the 'ovkey' on the tracking page to 'kw', or whatever variable name you used on your Adwords URL.
I don't know how tracking works on MSN because I have never used, so you will have to look it up. It should be very similar - just change what needs to be changed, probably just the dynamic keyword insertion code. The important thing is the process: have the PPC ad append the keyword to your tracking page URL, and then have your page grab the keyword, append it to your tracking link and send visitors on their merry way.
Hope that makes sense. Now if Yahoo would just aprove my ads before Valentine's day...
Email It















