Hi, Im trying to set up a little tracking system to store the username, IP and page when a google advert is clicked.

Javascript to call when a user clicks on an advert:

<script type="text/javascript">
function logClick() {
window.focus();
bug = new Image();

bug.src = 'http://forumgaming.com/track_click.php?pg=' + escape(document.title) + '&advertisement=' + escape(window.status);
}
</script>

track_click.php stores the info in the DB, it works fine as I have tested it by browsing to that page entering the url varriables manually

Advert displayed with iFrame:

<iframe src="../adsense.htm" frameborder=0 width=800 height=150 onFocus='logClick()'></iframe>

adsense.htm holds the adsense javascript provided by google. The advert displays ok but when clicked doesnt seem to be calling track_click.php with the appropriate variables. I have a feeling its the javascript function logClick(), but as I know nothing about javascript and got the code from a tutorial then I dont know whats wrong 😕

heres the tutorial link by the way: http://www.icemelon.com/tutorials/17/Track_Google_Adsense_Clicks.htm

Thanks

    Have you established whether anything is getting passed? When track_click.php runs, what is in the $_GET array?

    If PHP's not getting the information, then it is a Javascript problem, and would be better asked in a Javascript forum.

      Yes track_click.php appears to be working, as I have tested it myself by browsing to track_click.php?pg=some_value&advertisement=some_other_value

      It creates an entry in the DB as expected. So it must be a javascript issue I guess

        Write a Reply...