Skip

Tracking AdSense Visitors
January 25, 2005 5:40 PM   Subscribe

Website question. I'm helping a friend with a sports memorabilia site that sells merchandise. Currently he is using google adsense pay per click. Is there a simple way to track visitors who click from the ad to see if they are the ones who make a purchase? (MI)

He makes a few online sales a month but is unsure if they come from the pay per click ads or some print advertising he does. I know HTML and a little general programming php/mysql stuff. Any advice would be greatly appreciated. Thanks.
posted by keithl to Computers & Internet (6 answers total)
 
Google has a service specifically for this:

https://adwords.google.com/select/convtracking
posted by null terminated at 5:48 PM on January 25, 2005


If you're using a shopping cart of some sort, there's a chance that it assigns a session ID in a cookie to anyone who visits the site. All you need to do is capture the referrer data ($_HTTP['referrer'], I think) and store it along with the session ID in the database or cookie. Then log the session ID of the person when they make a purchase if it doesn't do that already, cross-index, the two, and voila.

Note: This won't track people who click through, log in, bookmark your site, and visit later to purchase. And there's all kinds of ways to avoid or spoof the referer field, so don't consider the information you get to be complete or accurate in any way.

That's the general gist of what you've gotta do, anyway.
posted by SpecialK at 6:07 PM on January 25, 2005


Thanks for the input and help. I checked the google link. Thanks, null and terminated. From the info it appears that google's tracking is voluntary and users would have to click on a link fro it to be reported. Personally, I think that's great that they are being so transparent. From a business perspective though I'm not sure how what percentage of people would actually click the link.

Special k, I kind of understand what you're saying but I'm pretty much a novice when it comes to this stuff. Would what you're saying be time consuming to set up?
posted by keithl at 7:25 PM on January 25, 2005


Well, it's either moderately impossible or it's relatively easy. I could probably write a book on how to do it.

If he's using a shopping cart that's hosted by an ISP or Web Host that won't allow him to edit the source code of said shopping cart, it's moderately impossible. (Aside: The way to do it would be to put an invisble gif somewhere on the page that is actually a PHP or CGI script and throws a cookie onto the user. More info on how to do that is available through google, but you would have to roll your own because of your need to track who the initial referer is, and THEN you'd have to flag that referer in your database when someone with your cookie successfully finishes a transaction.) Otherwise, if it's a shopping cart that he can edit, and it's written in PHP, it's easy and I can guide you through it.
So your first step, really, is figuring out what shopping cart he's using and whether or not you're allowed to tweak it, or even whether someone else has built a mod to track the base referrer of transactions. I think osCommerce has something like that.

The general algorithm you'll have to use is this: (I realize this is vague, but without knowing more, I can't really be more specific.)
1.) When someone comes to your site the first time and does not have a cookie from your site, assign them a cookie with a unique Session ID and also check $_SERVER['http_referrer'], or whatever its equivalent in perl mod_cgi or whatever other language you're using is. Throw that value either in your sessions table in your database (you'd need to add a field to the table for this, and update all of the pertinent queries) or in the cookie itself.
If the user already has a cookie from your site, then feel free to just read whatever rerferrer information is in there if you are storing it in the database.
(Note: If the shopping cart is using a sessioning engine such as php's session_register, just dump the referrer value into the session when the session is created, but not when it's updated, since you don't want to overwrite what's in that variable.)

2.) When someone buys something, grab that referrer field, whether it be in the sessions table (which usually gets cleaned out once in a while) or in the cookie, and drop it into a field in the transactions table.

3.) Build a report in php that will scan that transactions table and count the different referers. Snip to and count by domain, but allow drill-down functionality so that you can drill down to the actual queries themselves (because google will usually pass the search string in the referrer) by clicking on the domain, and then the actual transactions themselves by clicking on the query.
(don't forget to password protect this report... obviously, some of his customers might be miffed if he leaves their 'what they bought' open to world + dog.)
Even bigger note: I haven't seen or studied the referer strings, so I can't really tell you, *but* there's a good chance that you won't be able to discriminate between someone searching on google and clicking through on the actual search results link, and the adword itself. I'm not sure about this, so take it with extra salt.

Of course, like I said before, a few browsers allow you to turn off referrer transmission. Many people don't bother, but some people do. Therefore, you're never going to get a *totally* accurate count. But you'll at least get a general idea. Whether it's worth the effort to figure this out and hack it to your needs, or to switch to a shopping cart that will support this type of functionality. It seems easy and logical to me because I write this kind of thing all the live long day, but your effort level may vary.
posted by SpecialK at 11:14 PM on January 25, 2005


Sorry not an answer, but a pointer to possible answers...

There's a hack (#84) in O'Reilly PayPal Hacks that talks about tracking click thrus from google. Pretty much giving you details on the link null terminated gave you, and showing you a context in which is works, kinda useful.

There's also the Google Hacks Second Edition book that has a helpful chapter about AdWords.

Both of those together is probably what you need. I mention it because you can either go into your local computer book shop and skim the info you need in a lunch time, or if you don't want to leave your computer desk...

Sign up for the 14 day free trial for Safari at O'Reilly, add the two books to you bookshelf. You'll easily be able to get the info you need within the 14 days and then cancel the account at no charge (or keep it). Reading the info from the books where it's all gathered together is probably better use of time than Googling around for info on the internet.
posted by ModestyBCatt at 8:33 AM on January 26, 2005


Special K thank you so much for going the extra mile to deliver the answer. I really appreciate the effort. I'm not sure which cart he uses. I'll have to find out.
Also, thanks for the safari tip, ModestyBCatt. I'll check it out.
posted by keithl at 9:10 AM on January 26, 2005


« Older I just scored a bimonthly live...   |  I'd like to shoot a series of ... Newer »
This thread is closed to new comments.


Post