I have a page full of links that go to pdf's I want to track which links are being clicked. I thought I could do something like follows but am having issues:
<?
function track($link)
{
$sql = "UPDATE database WHERE something = 'something';
$db = new connection();
$result = $db->query($sql);
if($result){
header( 'Location: http://mywebsite/docs/. $link .' ) ;
}
}
?>
and my HTML would look like:
<a onClick="track(my_file_.pdf")">File Name</a>
Ok it looks like I am just going to use the link to pass the file name to a php script and once that is done I will redirect the user to the pdf.