Forum Moderators: coopster
Just make a page that does nothing but redirect to another page based on the querystring variable "URL". Then, when you want to create a link that sends someone away from your site, link to redirectpage.asp?URL=http://www.wherever.com
(replace .asp with .php or whatever language you're comfortable with)
Then just look in your logs and see how many hits you got to redirect.asp and all of the querystring data submitted.
I'm actually kind of surprised servers *don't* log this. This isn't even registered in server logs?
How is a server going to know where a visitor goes next? You only know where they came from as a matter of courtesy with the browser sending a referer header. When a visitor goes elsewhere, they just start connecting to the other webserver with their requests.
I'm actually kind of surprised servers *don't* log this. This isn't even registered in server logs?
There is nothing to log because it is nothing to do with your server.
HTTP is stateless anyway; once a browser has received a page it can close the connection and that is the last contact your server has with that client (web browser).
So has anyone figured out a way to track outbound clicks without making them redirects?
Only possible if you're happy to rely on JavaScript.
Use "OnClick" within the <a> tag of your link to call a function that loads a web bug image (single pixel) into the document. If the web bug is served by a PHP script (see below), then you can capture anything you want off the URL, which of course you render dynamically containing an ID for the URL that has been clicked, or the URL itself if you wish.
HTML with web bug click through tracking
<script type='text/javascript'>function oc(link)
{
document.write("<img src='imagesrc.php?url="+link+"'>");
}</script>
<a href='http://www.example.com' onclick='JavaScript:oc("www.example.com");'>Example</a>
imagesource.php
<?php// here you can log $_GET["url"]
header("Content-Type: image/gif");
require("singlepixel.gif");
?>
...of course you have to make yourself a singlepixel.gif file (just use your favorite drawing package) and dump it the same directory as imagesource.php.
Tim
Sorry, I'm in one of those moods today. ;-)