Coding For Online Success

Simple EPN Keyword Tracker for PPC/Organic Searches


ebay-partner-networkI’ve discussed in the past on how to capture keywords for EPN store front sites. Basically, if you’re driving traffic with PPC to your store fronts, or even if you’re promoting them with SEO, you’ll want to know what keywords are actually converting them.

To do this, you need to capture the keyword in your site and then pass it as a customid field to eBay. From there you’ll see the keyword in your transaction reports. I’ve worked on my function(s) for this, I still want to tweak them further, but I’ll provide them here so you can play with them in your own application. I want to first explain the general idea of how it retains ‘state’ throughout my site though. If you’re the visitor and clicked on one of my PPC ads (either Yahoo, MSN or Adwords), the referring URL passes some useful information to my site. My function looks for particular information and then determines if it can grab a keyword that was passed from the ad. Each program passes information differently. Once a keyword has been determined, my application then appends that variable (kw) to all links within the site. That way the user can visit multiple areas of my site before going to eBay, and my keyword will follow him.

I’ve considered sticking this in a session or cookie object, but for ease, I left it as a GET or POST variable depending on the situation. I know this part has confused others in the past.

I’ll try to break down the functions below and describe them as best as possible. Please feel free to comment or email me if something doesn’t make sense. This is all written in PHP (compatible with versions 4 or 5).

The first function is the primary getKeyword() function. This function has nested functions since I want to take advantage of code reuse:

span class=”st0″>”‘kw’‘kw’])) > 0){
                $kw                             = sanitize($attributes[‘kw’]);
        // check yahoo
‘OVKEY’‘OVKEY’])) > 0){
                $kw                             = ‘ysm’.sanitize($attributes[‘OVKEY’]);
        // check handling for msn
‘a’]) && $attributes[‘a’] == ‘m’‘HTTP_REFERER’‘HTTP_REFERER’], ‘q’, ‘msn’‘msnUnknown’‘msnUnknown’;
        // check handling for google
‘a’]) && $attributes[‘a’] == ‘g’‘HTTP_REFERER’‘HTTP_REFERER’], ‘q’, ‘goo’‘gooUnknown’‘gooUnknown’// now ad passed, check for organic

When I create ads at various PPC networks, I add the following to the URL This would pass a=y which would tell my app that the ad is Yahoo.  Once it’s know where it came from it needs to break the querystring and get down to the variable that contains the keyword. That is what the breakQstring() function is about. It requires the referrer, the variable that contains the keyword, and the label for add source. If no keyword is found (because no ‘a’ variable is passed from a ad), it will then check if this is a organic search result with getKeywordOrganic().

span class=”st0″>”‘HTTP_REFERER’‘’‘HTTP_REFERER’‘HTTP_REFERER’], ‘q’, ‘orgGoo’);
                // end google check
‘’‘HTTP_REFERER’‘HTTP_REFERER’], ‘p’, ‘orgYah’);
                // end yahoo check
‘’‘HTTP_REFERER’‘HTTP_REFERER’], ‘q’, ‘orgBing’

getKeywordOrganic looks at the referrer again and looks for the appropriate variable where the keyword is normally found. This function will handle Google, Yahoo and Bing.

span class=”st0″>”‘?’‘&’‘=’// clean up

breakQstring() is designed to disassemble the querystring and filter it down to simple variable value pairs and stop when if finds what it’s looking for. If there is a value, it will return the keyword to the parent getKeyword(). I simply call this function and set a local $kw variable. I want to note that I’m using $attributes, you’ll probably need to use $_REQUEST or $_GET or $_POST depending on your situation.

After you have a local $kw variable, you would then pass that to your rover link and add it to the customid field of that link. You should start seeing keywords, search network and organic information in your transaction reports at EPN.


  1. Pingback: PHP for Affiliate Marketers | Money-Code

  2. This is extremely interesting and it’s great of you to share your code and experience.

    A quick question, if you know of the answer… (I’ve been looking quickly through the eBay Developer network docs for this, but without luck so far)…

    If all I want to do is track the referrer code (say, in the customid field) in my rover code, is there a simple paramater I can add to the rover code?

    As in ….. &customid=[http-referrer] or something like that.

    All I would like to do is be able to view the specific referring URL that generated a transaction in EPN reports.

    Many thanks in advance.

  3. Robin.. thanks for commenting!

    I think you could do partial referrer. There is a limit on that field length and not sure what it is. For a while, I thought my keywords (not encoded) was causing problems so I restricted length quite a bit. I would be worried with two items.

    – properly encoding the referrer, you can’t have any ‘weird’ chars in there
    – worried about the length being too long.

    If I was you I would use SEO redirect technique, and then store the referrer in the database before sending them to their destination. You can see more about SEO redirects here:

    Again, thanks for commenting. Let me know if you have any questions.

Leave a Reply

Required fields are marked *.

CommentLuv badge

This site uses Akismet to reduce spam. Learn how your comment data is processed.