
Originally Posted by
pdstein
Is there a better way to do what I'm trying do?
Use AJAX. And here is how, add this:
Code:
onClick="track_the_click('1234')"
to the relevant links and add the JavaScript below to each page:
Code:
<script language="JavaScript"><!--
// Free with compliments from Seiretto ;-)
var url="http://www.mysite.com/clickTrackingScript.php?bannerID=";
function getHTTPObject()
{
if (typeof XMLHttpRequest != 'undefined')
{
return new XMLHttpRequest();
}
try
{
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try
{
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
} return false;
}
function track_the_click(id)
{
var http = getHTTPObject();
http.onreadystatechange = function()
{
if (http.readyState == 4) // 4 is complete
{
//alert(http.responseText); // uncomment to see the response!
}
}
http.open("GET", url+id, true);
http.send(null);
}
// -->
</script>
If you do not want any bots following your links in your scripts change the above line
FROM:
Code:
var url="http://www.mysite.com/clickTrackingScript.php?bannerID=";
TO:
Code:
var url1="http://www.mysite";
url2=".com/clickTrackingScript.php?bannerID=";
url=url1+url2;
// most bots are too stupid to put the two together so will not index it (at least currently).
Hope it helps.
Dave.