Forum Moderators: DixonJones

Message Too Old, No Replies

click tracking question

this can't be a new question

         

shasan

10:27 pm on Sep 17, 2003 (gmt 0)

10+ Year Member



K, I searched high and low for an answer, but my searching skills aren't what they used to be.

Does anyone know of a free PHP/MySQL click tracker (I want to track clicks on outbound links)?

thanks guys.
shasan.

killroy

10:52 pm on Sep 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The simplest solution is an inbetween page with an automatic refresh to the target page. This is how many download sites do it. It will show in your standard server logs.

Another simple solution is something like:

redirect.php?target=http://domain.com

which then outputs

Location: [domain.com...]

easy enough to do. Search for location redirect and 301 headers together with php and the like on google and you should find it.

SN

shasan

12:08 am on Sep 18, 2003 (gmt 0)

10+ Year Member



hey,
thanks killroy, I like the idea of them showing up in my standard server logs.

I don't understand the second example though. I gather that it will also make the clicks show up as requests in my server logs, but would redirect.php just take $target and refresh to it? kinda the same idea as the inbetween page?

cheers
shasan

amoore

12:41 am on Sep 18, 2003 (gmt 0)

10+ Year Member



You can use mod_rewrite to do this for you. Make a directory and just put a .htaccess file in it. Make that .htaccess rewrite all requests to be an external redirect to the URL requested. something like this ought to work:
RewriteRule ^(.*) $1 [R]
put it in a directory, say example.com/redirect/ (assuming you're running example.com)
Then, construct your offsite URLs like this [example.com] and people will be redirected to remote.example.com/foo.html

Now, when you want statistics about this, look through your logs (probably using a log analyzer) for requests like example.com/redirect/... and you'll have the URLs that you're sending people to.

I've used this before, but I can't find the exact .htaccess file I used. I'm pretty sure that one is close, but you may have to fiddle with it for a few moments.

If you don't run mod_rewrite and don't want to, you can make a mod_perl module like this to do similar:

package Redirect;
sub handler {
my $r = shift;
$r->method('GET');
$r->headers_in->unset('Content-length');
$r->content_type('text/html');
$r->header_out('Location' => $r->path_info() );
return 302;
}
1;

Use it the same way I recommended using mod_rewrite above.

Lastly, I think there is a mod_redirect floating around, but I'm not sure if it's officially supported by the apache.org guys.