MUST Have PhpBay Pro Mod (FREE)

First off, If you are creating eBay niche stores and you aren't using PhpBay Pro then stop right now.  Forget BANS or any free-ebay plugins that you might have found.  You are just wasting time.  Go, check out PhpBay Pro now.  (Go ahead... I'll wait).  Ok.  Now that we are all on the same page, I'll get on with my story.

See, I was talking with Hanji (from and he was asking me about the Custom ID capabilities of PhpBay Pro.  See, he's a genius who writes all his own stuff so he can do all sorts of cool tricks with PPC campaign tracking, and whatnot, using Custom ID with EPN.  He suggested that I look for a plugin or Mod for PhpBay Pro because surely someone else out there wants the functionality.  Sure enough, I found a great post by Anthony Wakefield on the PHPBay Forums.

Here's what his Mod can do for you:

  • Show you exactly which Search Engines & Search Keywords generate sales.
  • Show you what referring sites generate sales.
  • Incorporates the Previous '12th Parameter' Custom ID, so you can define this as you wish, and it's added on to the search engine and referrer info.
  • Track Adwords or other Ad Campaigns via a referring URL & 30 Day Cookie.

Using his Mod, you can download your Transaction reports from EPN (Make sure and download all events and keep it checked on All Programs) and you'll see the following format in your  Custom ID field.

[KW = Airport Express A1264] - [SRC = google] - [MED = organic]

KW is Keyword, & SRC is Source (ie. yahoo/google/msn)

If you've entered your own Custom ID field in the [phpbay] tag (although, if you had luck with this, let me know, I'm having issues) then you should see ad additional [CID = something] chunk in there.

To use Anthony's MOD you just need to edit your auction.php file.  This should be in the root of your site (it's one of the files you uploaded when you installed phpBay Pro).

Locate the following code:

$ktv["ccid"] = $_REQUEST["ccid"];

and replace it with:

#PHPbay CustomID Mod By Anthony Wakefield - Anteck On PHPBay Forums
# String Splitter
function strbet($inputStr, $delimeterLeft, $delimeterRight, $debug=false) {
$posLeft=strpos($inputStr, $delimeterLeft);
if ( $posLeft===false ) {
if ( $debug ) {
echo "Warning: left delimiter '{$delimeterLeft}' not found";
return false;
$posRight=strpos($inputStr, $delimeterRight, $posLeft);
if ( $posRight===false ) {
if ( $debug ) {
echo "Warning: right delimiter '{$delimeterRight}' not found";
return false;
return substr($inputStr, $posLeft, $posRight-$posLeft);

# If 12th Parameter Set, Format For Use In Referrer Custom ID
if (isset($_REQUEST["ccid"])) {

# Google Analytics Cookie Extraction & Write-Out Referrer Custom ID
if (isset($_COOKIE["__utmz"])) {
$utmz = $_COOKIE["__utmz"];
$garef = '|'.$utmz.'|';

$source = strbet($garef ,'utmcsr=','|');
$medium = strbet($garef ,'utmcmd=','|');
$term = strbet($garef ,'utmctr=','|');

$searchstring = '[KW = '.$term.'] - [SRC = '.$source.'] - [MED = '.$medium.']'.$PRESETCUSTOMID;

# Filter Unfriendly URL Characters
$searchstring = str_replace('_','-',$searchstring);
$searchstring = str_replace('/','-',$searchstring);
$referrerinfo = $searchstring;
$adsearchkw = ' - [KW = '.$term.']';
$adsearchkw = str_replace('_','-',$adsearchkw);
$adsearchkw = str_replace('/','-',$adsearchkw);

# Check For Ad Cookie, If Exists Then Write Into Referrer CID
if (isset($_COOKIE["AdwordsID"]))
{$ADVERT = $_COOKIE["AdwordsID"];
$referrerinfo = '[AD = '.$ADVERT.']'.$adsearchkw.$PRESETCUSTOMID;
# Pass Referrer CID onto PHPBay CCID
$ktv["ccid"] = $referrerinfo;
# End Of Mod

But, Anthony isn't done yet. He also created a system for passing a URL Referrer which then turns into a 30 day cookie. This is a Theme Mod that sets the cookie and if you want to use it you need only to edit your header.php file in your WordPress theme.

What it enables you to do is pass a Referrer ID from your PPC link by appending ?ad=ReferrerID to the end of the URL. When you do this, a cookie is set on the users computer for 30 days. Now, if they come back to the site three weeks later and buy something, you can still see that they originally came in via that ad. Also, it will add the original search keyword used to find the PPC Advertisement.

Here's what some example output:

[AD = ReferrerID] - [KW = refurbished iphone 3gs for sale] - [CID = 32GB iPhone]

So, to use it, edit your header.php (or equivalent file) on your site and add the following code:

<script type="text/javascript">

function geturlvar( name )
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
return results[1];

<script type="text/javascript">

function Set_Cookie( name, value, expires, path, domain, secure )
var today = new Date();
today.setTime( today.getTime() );

if ( expires )
expires = expires * 1000 * 60 * 60 * 24;
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );


<script type="text/javascript">

var adwordsurlref = geturlvar( 'ad' );
if (adwordsurlref>""){Set_Cookie( 'AdwordsID',adwordsurlref , 30, '/', '', '' )


There ya go! I just added mine yseterday so I can't wait to look at my EPN Transaction report today. I'll follow-up with you all once I do, though.

Also, as I mentioned before, this Mod is FREE, but Anthony certainly spent some time on it. If you use it and find that it's working well for you, and saving you some time, please consider a Paypal donation. Heck... just buy the guy a beer, right? "payments at" is the e-mail address you can use to send a paypal donation to him. (just replace " at " with "@", I didn't want him to get spam harvested because of my post)

NOTE: If this formatting is weird for you, then just head over to to see Anthony's original forum post.