About MeArchivesHow TosWhat Is?Generate CashCase StudiesMediaResourcesMy SitesAdvertiseNewsletterContact

Quick-N-Dirty PPC Keyword Tracking

March 10, 2008

Miscellaneous

It’s a good idea to track which of your keywords are converting into sales so you can scrap the one’s that are just costing you money. If simple keyword tracking is what you are after, this post should give you the steps to do just that. This approach is extremely simple. It will not store anything in a local database at all. If you have a landing page (not the framed approach), it will simply accept the keyword from the query string and create a cookie (text file) on the users computer. The page on your site that redirects to the offer will scoop up the keyword from the cookie and dynamically create a link to the offer by simply adding the keyword in the sub id parameter. You will then be able to check your reports and any sale or lead will show which keyword brought the conversion. I will cover the framed landing page way too. It’s pretty much the same but with less steps.

In some cases the keyword may be visible to the end user (for sure with the frames approach). Mostly it won’t be with all of the redirecting going on from PPC engine to landing page to affiliate network to offer, etc. And in the cases where it will be seen, the end user probably won’t care or even notice. It’s still an area of possible concern though so I thought I’d mention it. Since the keyword is the sub id, all of the reports at the affiliate network will show the converting keywords. That can be a potential problem but nothing I’m too concerned about myself. It’s a simplified, free way to track keywords without much code. It should work on any serving running PHP, including WordPress blogs.

Links To The Landing Pages (for framed and non framed solution)

First off is creating links to your landing pages from the PPC engines (destination URLs). In this example lets assume your landing page is at FreeFishOils.com. (FreeFishOils.com is not setup as a live example, I just wanted so use something other than YourLandingPage.com for my examples) It depends on the search engine what your URL will look like. I’ll provide a few examples below.

  • MSN adCenter: http://www.freefishoils.com/?kw={keyword}
  • Yahoo Search Marketing: http://www.freefishoils.com/ (Be sure to turn on tracking URLs. Yahoo will add the keyword to the end automatically.)
  • Google AdWords: http://www.freefishoils.com/?kw={keyword}
  • 7Search: http://www.freefishoils.com/?kw=###KEYWORD###

We’ll need some PHP code on the landing page to get the keyword, etc. but first I want to talk about the affiliate link(s) on the landing page.

Say, on the landing page FreeFishOils.com I have affiliate links for Children’s Fish Oils and Omega Berry Fish Oils. To keep the keyword as hidden as possible, we will setup redirect pages for those links. I might call the redirect pages; childfishoil.php and berryfishoil.php respectively. Those 2 php files will have code that will grab the keyword from the cookie and create the affiliate URL on-the-fly and redirect to it. Be sure when creating or changing your links on the landing page that they link to the redirect script (php file). Using the redirect method will also make this doable for those that use WordPress without requiring a plugin.

Creating The Keyword Cookie (non framed solution only)

The following code will grab the keyword from the querystring and store it in a cookie. If you don’t know what I mean by that it won’t interfere with you being able to get this to work. Just follow these steps and you should be OK. (this is not done for framed solutions)

Include this code at the top of your php file (the landing page).


Click the image above for a text file so you can copy and paste the code.

The above code will simply create a cookie with the keyword that was used prior to the user clicking on a text ad. Remember in our URLs the keywords were dynamically included at the end. It first looks for a value in kw. If it’s empty, it looks in another parameter that Yahoo passes over in YSMKEY.

At this point we should have our keyword in a cookie.

Including a SubID or TrackingID in the Affiliate URL (framed and non-framed)

The affiliate URL that you will need will depend on the affiliate network or merchant and whether they allow sub IDs/tracking IDs. Make sure the URL you use is expecting the Sub ID to be appended to the end, something like &subid=. That way our script can add the keyword right on the end of it. Here are a couple examples:

  • Commission Junction: http://www.dpbolvw.net/click-2838761-10378494?sid= (GoDaddy Hosting link)
  • NeverBlue Ads: http://nbjmp.com/click/?s=25104&c=68835&subid= (Free 3D Browser Games link)
  • ClickBank: http://klock1975.mikegeary1.hop.clickbank.net/?tid=

Get your link ready and I’ll explain what to do with it next.

Using Framed Pages With Your Affiliate URL (framed only)

If you are just using a framed page you should change the root file name to include a php extension. For example index.php.

Your code will be something similar to the following (using the ClickBank URL as an example):

Click the image above for a text file so you can copy and paste the code.

Your keyword will be visible in the address bar of the browser so beware.

Redirect Pages And Getting Value From Cookie (non-framed only)

Now for the code on the redirect pages. Remember in the example above we created the pages childfishoil.php and berryfishoil.php. The code for those pages will be simple. I’ll show you example code for one of the fish oil product redirect pages. The code will grab the value from the cookie and append it to the affiliate URL, then redirect to the offer page.

This should be all the code you need to redirect to the Omega Berry Fish Oil product on berryfishoil.php. (for example)

Click the image above for a text file so you can copy and paste the code.

That should be it for the quick-n-dirty PHP PPC keyword tracking solution. If you have any questions please put them in the comments and I’ll be glad to help.

About Keith Lock

Keith has been in the affiliate marketing field for 10+ years working in a variety of niches along the way. His extensive technical background has allowed him to gain a significant advantage while marketing online. Keith primarily writes detailed step-by-step guides and product/service reviews in the make money online niche.

View all posts by Keith Lock

© Earn A Living Online in Your P-Jizzle's.

Subscribe

Subscribe to get alerted by e-mail when a new article is added.

Get Exclusive Money Making Tips:

Market Samurai Free

4 Responses to “Quick-N-Dirty PPC Keyword Tracking”

  1. Stan Says:

    Keith,

    Thanks for the write up…very nice. I’m having a problem getting the framed version of the code to work though.

    I’m testing it on 7 Search and when I search my keyword and click on link this message comes up on the screen:

    “We’re sorry, but we are unable to process your request because the link you have used is invalid”

    Now My normal link will work fine so I’m guessing I messed up the php. When making the index.php file in Cpanel do you create it as a text document, html document, perl script, or shell script? I saved the file as index.php and have tried it as a text doc and a shell script. For the code on the page I just copied your code for Iframe and put in my affiliate URL. Then in 7 Search I just put http://www.mylink.com/?kw=###KEYWORD### as the destination URL.

    Any suggestions?

    Reply

  2. Keith James Lock Says:

    Hey Stan,

    Hmmm…the affiliate link might not be generating properly. Is it a MaxBounty campaign? If so I’m not 100% sure how their subid is to be passed.

    Your destination URL is correct for 7Search. Can you do me a favor and enter the destination URL into your browser and substitute ###KEYWORD### with a test keyword, doesn’t matter what, just the word test would be fine. Then click View Source and copy and past the html and send it to me. Hide anything that you don’t want to share. You can paste into the comments here or email it to me. Either way is fine.

    Also, check with your affiliate network (MaxBounty or whomever) and see what the maximum is allowed for a subid.

    To be honest I have never used CPanel. I’ve always created files from scratch with Notepad and uploaded via FTP, but I did a quick search and it seems that Text Document would be the correct choice.

    Reply

  3. Stan Says:

    I’m an idiot…I was not adding the “&s1=” to the end of the maxbounty code. It does work now for maxbounty. But its weird how the one offer just redirects (even though it should Iframe) while a few test offers act like a normal Iframe. But both times the keywords do get logged as sub ids so it doesn’t matter.

    Reply

  4. Keith James Lock Says:

    If you feel like sorting out the redirect problem I may be able to help out….let me know…
    but I’m glad it’s working for the most part…

    Reply

Leave a Reply