Keyword Tracking The Right Way
To build on three previous posts Why Use Tracking Code, How To Put Tracking Code On Your Landing Page and How To Cloak Your Affiliate Links, the intention of this post is to inform you on how to track the keyword someone used to get to your site from a PPC (Pay Per Click) Ad, no matter which page they come in from.
The problem that people have that made this post necessary is losing the keyword when someone comes in either from a different page or visits the page, leaves and then comes back. Without knowing which keyword got the person there in the first place, marketers like you and me are lost on how to properly spend our money and on which keywords are terrible at converting. We definitely need that information, so we must make sure to do our best to track it.
Now going into this post, I have to assume three things: you can follow instructions, you are using one of the major search engines for your CPC ads and you are using PHP for your web pages. With that out of the way, let's proceed..
In the header of your PHP files, you'll want to include the following code-
Once you've placed your keyword tracking code in your header(s), you'll need code in place to pass the captured keyword to your hop-link. If you aren't familiar with hop links and passing information using them, please read How To Put Tracking Code On Your Landing Page.
Additionally, if you'd like to learn about cloaking your hop links, please read How To Cloak Your Affiliate Links.
Now to extend the post on cloaking, you can modify your jump.php file with the following code-
It's really as simple as that. The first page captures the keywords and feeds them into the jump.php for Azoogle (or whichever network you're using) to track. What's more is that you can track additional information just by doing the same thing with other information you pass (such as the name of the ad group, specific ad, etc.) in other cookies. Then, you can just append that to the actual jump link's 'sub' tracking variable using a pipe (|) to separate the different variables, respectively.
So there you have it, proper keyword/ad tracking with cloaked links.








January 2nd, 2008 at 8:25 pm
Hi Scott — I gave this a try and I got the following error: Parse error: parse error, unexpected ‘;’ in /jump.php on line 10. I used the following jump code:
Does that look right? Thanks for posting this — i’ve been looking for info on this online for a few days.
January 3rd, 2008 at 1:18 am
@Phil: Oops, that sucks. Well, I can’t see the code you pasted but if you copy it to a .txt file on your server, I can see what’s wrong. Or just tell me which code you used and I’ll look into it. Thanks.
January 3rd, 2008 at 11:03 pm
No biggy — I broke my keyword list into groups for each phrase, then assigned each one a unique subid, then used your original jump code and it works great. Keeps azoogle from seeing the actual terms too, i think, which is cool. If I need to track by individual keyword down the road, i’ll try this code again. Thanks
January 4th, 2008 at 8:57 am
@Phil: Yeah, the last thing you want is for other people to steal your keywords.
On the flip side, however, it’s nice to get indexed for certain things for organic traffic later on.
January 6th, 2008 at 8:20 am
the part that I am not getting is how to set the aff links using this new tool.
I posted that I was trying to do this with no luck.
case ‘jumptexthere’;
$URL = ‘http://afflinkhere.com/1234?sub=’.$_GET['kw'];
break;
January 7th, 2008 at 5:26 pm
@topcash: You put them in your jump.php as exemplified in the jump_php2.txt I posted.
January 15th, 2008 at 10:46 am
If you use pixels from google conversion code. Why would you even need to use a php to send the keywords?
January 15th, 2008 at 8:58 pm
Has anyone been able to get this to work? Not much luck here.
January 16th, 2008 at 10:17 am
@tc: Because this way, you can tell which keywords convert into sales by viewing your affiliate reports.
@gweeds: What seems to be the trouble?
January 16th, 2008 at 6:17 pm
I received an unexpected ; error.
January 16th, 2008 at 6:57 pm
@gweeds: Just IM it to me.
January 16th, 2008 at 7:40 pm
Im trying to ask why I would need to use the keyword tracking if I have a conversion pixel on the thankyou page.
Once a conversion happens then I see it in my google stats
January 16th, 2008 at 9:01 pm
@tc: Right, and I answered you- with keyword tracking you can tell exactly which keywords turn into conversions. You send the keyword through to your affiliate network jump link with the customer and if they convert, you know. If it doesn’t convert, you also know. This way you can determine which keywords work and which don’t. With Google’s conversion pixel alone, you can see which keywords people are using to get to your site and moreso if you have your own product and can place it on the “thank you” page but if you are an intermediary, you don’t have that luxury. That’s why networks like Azoogle, Neverblue, CJ, etc. allow you to send tracking information via the jump link. I hope that helps.
January 17th, 2008 at 4:07 am
Great post!
Can this be modified to track which keywords people are using to find you in organic search?
I am looking for a way to match up info from log files with click outs to offers.
January 17th, 2008 at 12:28 pm
@Chuck: Well, I haven’t done it yet but I’m sure there’s a way. That’s a good idea.
January 20th, 2008 at 8:23 am
How could I incorporate this on a site that has offers from seperate companies on the same page… For example some offers I run use ‘clickref=’ and others use ’sub=’.
Asides from that problem thanks for the post - it will be great if I ever get it working
January 20th, 2008 at 6:58 pm
@Chris: You might create a different jump.php for each different company and track it that way. There are several ways to do it but this seems the most simple.
January 24th, 2008 at 8:00 am
Im not sure what I am doing wrong here. I can get jump.php to work great, but jump2 just does not want to work.
When every I click the /jump/link it brings me to a blank white page. No hopping over to the aff link.
January 24th, 2008 at 10:25 am
@tc: Do you have your htaccess pointing to the new jump2 for the ‘link’ you’re trying to use?
January 24th, 2008 at 2:22 pm
I put all jump2 data into jump.php
I have the php on the main.php header
January 24th, 2008 at 3:56 pm
@tc: You might want to dump the $_REQUEST variable to the screen and comment out the header() request temporarily just to see what is being requested. You can do that by doing a print_r($_REQUEST) or a var_dump($_REQUEST).