This tutorial shows how to track your vistors click using simple php and Ajax To implement the click tracking tool we need to create 2 files:
Demo.html: This file contains the html with the links and the Ajax code.
clickTracker.php: This files will be called by Ajax and records the click event.
DEMO.HTML will look like this
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8? />
<title>Ajax click tracking example</title>
<script language="javascript" type="text/javascript">
function getHTTPObject(){
if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP");
else if (window.XMLHttpRequest) return new XMLHttpRequest();
else {
alert("Your browser does not support AJAX.");
return null;
}
}
// Change the value of the outputText field
function setOutput(){
return true;
}
// Implement business logic
function doTrack(element){
httpObject = getHTTPObject();
if (httpObject != null) {
dst = element.href;
src = document.location.href;
httpObject.open("GET", "clickTracker.php?src="+src+"&dst="+dst, true);
httpObject.send(null);
httpObject.onreadystatechange = setOutput;
}
}
var httpObject = null;
var src = null;
var dst = null;
</script>
</head>
<body>
<a href="http://www.mistonline.in/wp" onclick="doTrack(this);" > Test Click </a>
</body>
</html>
Now our clickTracker.php file
We will write data dynamically using AJAX to a simple text file, If you are not sure how to read/write data using
a text file in php then
Code:
Thats it finished.Now you can track your website clicks, Thanks ajaxf1
Incoming search terms:
- php click tracking tutorial (11)
- php click tracker (8)
- ajax click tracker (6)
- ajax click tracking (5)
- ajax hit counter (5)
- ajax tracking clicks javascript (5)
- ajax click counter with php (5)
- php click tracker tutorial (5)
- php ajax tracking (4)
- dst = element href (3)
- email\s HTML code go to a php click tracker (3)
- php click tracking (3)
- track clicks php tutorial (3)
- php click tracking script (3)
- doTrack(element) (3)
- how to show record in click event ajax php (3)
- How to track Buttons clicked tracking - php tutorial (3)
- ajax click event php (3)
- ajax onclick counter (2)
- ajax php clock (2)
- simple click tracker (2)
- click tracker php (2)
- simple ajax example in php (2)
- fetch record with php ajax tutorial (2)
- simple ajax and php clock (2)
- ajax tutorial for image hit counter (2)
- ajax visitor counter (2)
- ajax w3c tutorial (2)
- ajax who is online tracker (2)
- php ajax mysql click counter (2)
- clicktrack ajax php (2)
- clicktracker (2)
- ajax click tutorial (2)
- how to show image through ajax in php (2)
- click tracking php tutorial (2)
- php ajax hit counter (2)
- php ajax click tracker (2)
- simple php click tracking (2)
- onclick event on image ajax et php (1)
- php click tracking scripts (1)
You will also be interested in ,
- Ajax Page With PHP
- Automatic Ajax Loading Images With Prototype
- Ajax and Jquery
- Arrays In PHP
- Replacing a string using php
- Display text file line by line and delete certain lines using php
- Simple php watermark script
- Quick method to prevent cross site scripting in php
- Change background color using php for a webpage
- Export mysql tables to excel new version using phpxls pear spreadsheet writer
