Yes, make it link to a script on your site. Say bannercounter.php4
the href would be something like
bannercounter.php4?bannerid=%bannerIDhere%&bannerURL=%urlencodedbannerURLhere%
then on the script you do something like
$sql_cmd="INSERT INTO bannerclicks (banner) VALUES ($bannerID)";
mysql_query(blablabla
// after you are done loggin you use the header command to redirect the output
header("Location: http://".urldecode($bannerURL));
exit;
Saludos
Gerardo