I have a script that uses PHP to automatically redirect a user to an outbound URL. I'm trying to incorporate Google Analytics into the script so that I'm tracking outbound links. It says to add a JavaScript attribute like this:
<a href="http://www.example.com" onClick="javascript:urchinTracker ('/outgoing/example_com');">
But the redirect doesn't use the <a href> tag, it looks like this:
if(headers_sent()) {
$outbound_url = "http://".$row['URL'];
echo "<script type='text/javascript'>location.href='$outbound_url';</script>";
} else {
header ("Location: " . $outbound_url);
}
Can someone tell me how I can "merge" the two?