Forum Moderators: DixonJones

Message Too Old, No Replies

How to track clicks on links?

A beginner question

         

mo_jeff

8:43 pm on Oct 5, 2004 (gmt 0)

10+ Year Member



My apologies if this question is too basic - I've spent a good amount of time going through this forum and others looking for a straightforward answer, but no luck so far...

I have a site built with plain HTML, which is essentially a collection of links with my comments and reviews on each one. It's just a small hobby site of mine, but it's slowly getting more traffic from fellow enthusiasts, and I'd like to start tracking where these people are clicking off to.

Is there a relatively simple way to track this? I've seen plenty of sites use the syntax "www.myownsite.com/script/redirect?www.thenewsite.com" but can't figure it out myself. Seems to be PHP(?) or something, of which I know nothing. As I mentioned in the subtitle of this thread, I'm new to anything but HTML (and not even all that good at HTML!)

Anyway, no more rambling from me - thanks for any help :)
mo.

dcrombie

1:29 pm on Oct 6, 2004 (gmt 0)



If your links are plain HTML then a click takes the user out of your site and there's no way to record it.

If you links go to a server-side script (eg. PHP) then you can increment a counter and THEN redirect the user to the linked site.

This can also help protect your site from 'content scrapers'.

mo_jeff

5:28 pm on Oct 6, 2004 (gmt 0)

10+ Year Member



Thanks dcrombie - looks like I'm going to have to learn PHP! I'm sure there's a dummies book out there somewhere! lol

If anyone knows of a good online resource for beginners, it would be greatly appreciated.

Cheers,
mo.

larryn

7:56 pm on Oct 6, 2004 (gmt 0)

10+ Year Member



d,

Heres some PHP to get you started. Put in it its own file, called for example "clickout.php", nothing extra in the file (esp at the end) or it might not work!

To capture the clickout, change your HTML from

<a href="www.thatsite.com">{/code] to [code]<a href="clickout.php?www.thatsite.com">

<?php
header("Location: http://".$_SERVER['QUERY_STRING']);
exit;
?>

Larry

jdancing

8:11 pm on Oct 6, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Check one of the "ASP Scripts" sites and you'll find some free/cheap ready-made scripts that will track the number of clicks on each link.

I used such a script to weed out the affiliate programs that liked the customers I sent them but didn't like sending the checks. It sure can be eye opening when you see 100s of click-throughs to one affiliate program and somehow they never have any conversions, while a similar affiliate program will have a nice conversion rate.

mo_jeff

1:23 am on Oct 7, 2004 (gmt 0)

10+ Year Member




Thanks larryn and jdancing!

I tested out the clickout.php file - at first I couldn't see how it worked, but I just checked my log file and saw that the "cs-uri-stem" column now shows the link that was clicked next to "foldername/clickout.php". Opening the log file in Excel allows me to tally all of the links in that column. This is a great start! Many thanks :)

My thirst for data is sated - for now!

Cheers,
mo.

mo_jeff

9:58 pm on Oct 11, 2004 (gmt 0)

10+ Year Member



I'm loving this new tracking that you've given me - I do have a question, however. It seems that search engine bots are seeing each redirect as a page that's part of my domain? My logs show msnbot following each redirect:

(...snip...) GET /foldername/clickout.php www.example.com (...snip...) msnbot/0.3+(+http://search.msn.com/msnbot.htm)

Where the URL in question is www.mydomain.com/foldername/clickout.php?www.example.com

Should I be adding the PHP file into a folder that's blocked with a robots.txt? Or is this just the bot following links off to another site? I get dozens of these entries, one after the other, in my logs, so it looks like it's indexing each one.

Thanks for your thoughts!
mo.

larryn

5:27 am on Oct 12, 2004 (gmt 0)

10+ Year Member



jeff,

Do you care? Personally, I pretty much ignore the bots, but if you do care, yes, put the script in a hidden from robots place:

User-agent: *
Disallow: /clickouts.php

Larry

mo_jeff

11:02 pm on Oct 12, 2004 (gmt 0)

10+ Year Member



Do you care?

Good point! Maybe not... I guess I like to keep everything as clean as possible, and I worry about getting strange pages showing up as search results. What prompted it was a sudden drop in SE referrals over the last day or so - but I think it's coincidence.

Thanks for all your help Larry!
mo.

ddent

10:19 pm on Oct 26, 2004 (gmt 0)

10+ Year Member



Be careful with these scripts that you don't open your site up to XSS attacks.