You could create an intermediate page on your server, maybe something like (out.php). You could then redirect all traffic to the out.php page, do the processing there, and then redirect.
<a target="_blank" href="/out.php?url=<?php echo urlencode($this->product['from'])?>">
<img src="http://xxx.com/data/images/buy.jpg" alt="Buy!"/>
</a>
out.php
<?php
$url = urldecode($_GET['url']);
/*
MySQL CODE TO PROCESS TRACKING
*/
header("Location: ".$url);
exit;?>