Share:
POST
TWEET
SHARE
SHARE
EMAIL

PHP affiliate links with eBay's EPN

By Chris Dawson April 6, 2008 - 1:08 pm

If you’re a member of eBay’s new Partner Network and you use text links to send traffic to eBay, it’s probably pretty important to you to be able to create those links quickly. But if you’ve used the new link building tool on the EPN site, and especially if you opted for geotargetting, you probably looked in horror at the pile of javascript it produced, and wondered how you were ever going to be able to create a text link without running through the tool every single time.

Fortunately a thread by SlightlyUnhinged on the UK Affiliates’ Board dissects the anatomy of an affiliate link, and has allowed me to create a new PHP function to make the text links in TameBay. If you make a lot of text links to eBay, then this might prove useful.

It’s offered here without any explicit or implied warranty and you are strongly advised to test in your own environment before use. ๐Ÿ™‚

Here are the PHP functions:
<?

function get_country($country_code) {
$US = "711-53200-19255-0";
$IE = "5282-53468-19255-0";
$AT = "5221-53469-19255-0";
$AU = "705-53470-19255-0";
$BE = "1553-53471-19255-0";
$IN = "4686-53472-19255-0";
$CA = "706-53473-19255-0";
$SG = "3423-53474-19255-0";
$HK = "3422-53475-19255-0";
$FR = "709-53476-19255-0";
$DE = "707-53477-19255-0";
$IT = "724-53478-19255-0";
$ES = "1185-53479-19255-0";
$CH = "5222-53480-19255-0";
$UK = "710-53481-19255-0";
$CN = "4080-53484-19255-0";
$NL = "1346-53482-19255-0";

return $$country_code;
}

function aff_link($url,$text,$customid,$country){
$target = get_country($country);
$prefix = "http://rover.ebay.com/rover/1/";

echo "<a href="".$prefix.$target."/1?campid=XXXXXXXXX&customid=".urlencode($customid)."&toolid=10001&mpre=".urlencode($url)."" title="".$text."">".stripslashes($text)."</a>";
}

?>

Obviously you need to replace xxxxxxxxx with your own campaign ID.

And here’s what you need to put in your text:

<? aff_link("URL","link text","custom ID","country"); ?>
where

  • URL is the eBay URL you want to link to
  • link text is the clickable text you want to use (which will also appear as the title attribute of the link)
  • custom ID is like CJ’s SID, so that you can append a specific ID to any link, showing you which perform the best
  • country is the two letter country code relating to the program you’re promoting with this link (US, UK, FR, DE, AU etc.)

As it stands, this doesn’t do any geotargetting; you have to pick the programme you’re promoting. We’ll save the javascript for another day ๐Ÿ˜‰

Making affiliate links in WordPress

  • Copy the first section of code (the PHP functions) into the functions.php file in your theme (don’t delete anything else that’s in there though!).
  • You’ll need a plugin that allows you to execute PHP code within the body of a post. We use Exec-PHP.
  • Whenever you want an EPN text link in the body of the post, paste in the second bit of code and edit accordingly.

Hope that’s useful to someone. I don’t pretend to be a PHP expert, so if someone else can do a better job, please give us a shout.

Comments are closed.

Featured in this article from the Tamebay Guide โ€“ companies that can help you grow and manage your business.

See More Companies >

Recent Comments

1 hour ago
Elvis: haha, how fitting lol....
2 hours ago
Bill Gates: It doesnโ€™t look like the user interface has been redesigned since 2002 either. Is that...
3 hours ago
jim: and again, we dont give a hoot what ebay do as long as were...
7 hours ago
Dav: Really how many more schemes can eBay keep coming up with? They are far beyond...