Hello Reader's, If you want to get the records of visitors that visits your webpage then in this blog you can learn and build your own. Here we will develop it by using PHP and Ajax.
Page counters are easy to get and install but if you want to track individual pages you need to develop your own. So let's get started doing this.
Step 1. Open the page which you want to set the visitor counter and at the bottom of the page create an ajax function that will send a request to increment the count every time page open. And it's code will go like this:-
In the code above first, you have to include the jquery file and next get the plage id. Now you have to send this id to another function name as ViewCountPlus inside Place controller. So every time when page load this function will send page id to this function for increment the count.
Step2. Create a controller with name Page.php and write a new function in it. And it will go like this:-
public function ViewCountPlus()
$this->db->set('view_count', 'view_count+1', FALSE);
In the above code the page id is get and table "place_sec_details" with column name "view_count" is incremented by 1. You have to create a new column with int type that will keep the traffic records corresponding to a particular place. Now you have got the visitor count and you can show this number in your same page and it's code will go like this:-