PHP Classes

PHP Visitor Tracking: Track visitor location and details using MySQLi

Recommend this page to a friend!
  Info   Example   Demos   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 52%Total: 1,161 All time: 3,267 This week: 67Up
Version License PHP version Categories
php-visitor-tracking 1.21Freeware5.0HTML, PHP 5, Databases, Geography
Description 

Author

This class can track visitor location and details using MySQLi.

It records the details of a site visitor inserting a record in a MySQL database using MySQLi.

The class looks up the user IP address using the NetIP.de Web service to retrieve the user country, domain, state and town name.

It also records in the database the current page the user is visiting, the referrer page and the current date.

The class can also display on a Web page a paginated listing of the latest visitors details.

Picture of Tyler Heshka
  Performance   Level  
Innovation award
Innovation award
Nominee: 1x

 

Recommendations

how to retrieve user ip address from the database
retrieve user ip address from the database

Example

<?php
   
/**
     * include database settings
     */
   
require_once( 'src/_installation/db.php' );

   
/**
     * include the class
     */
   
require_once( 'src/class.visitorTracking.php' );

   
/**
     * instance the class
     */
   
$visitors = new visitorTracking();
?>

<html>
    <head>
        <title>PHP + MySQLi - Visitor Tracking Class</title>
    </head>

    <body>
        <div style="float:left;"><a href="http://tyrexi.us/visitorTrackingDocumentation/" target="_blank">Documentation</a></div>
        <div style="float:right;"><a href="examples/map-example.php">Map Example</a></div>

        <br>

        <h2>This visit has been tracked.</h2>
        <pre><?php echo $visitors->displayThisVisit(); ?></pre>

        <br><hr><br>

        <h2>All tracked visits:</h2>
        <pre><?php echo $visitors->displayVisitors(); ?></pre>
    </body>
</html>


Details

visitorTracking

GitHub License Software Version Github Downloads

visitorTracking is a simple PHP class to gather visitor information, and store it in a database using MYSQLi. It's more modern and complete than others I have seen around on Google/HotScripts. (SQLi, oop(ish?), etc...) No bells or whistles, fully customizable.

Download

Old Versions

Documentation

http://tyrexi.us/visitorTrackingDocumentation

Demo

http://tyrexi.us/visitorTracking

Install

  1. Upload the files to your server.
  2. Edit the database configuration ( `src/_installation/db.php` )
  3. Create the `visitors` table in your database. (`src/_installation/visitors.sql` )
  4. Instance the class in your code.

Usage

//define database
define( 'DB_HOST', 'localhost' );           // set database host
define( 'DB_USER', 'root' );                // set database user
define( 'DB_PASS', '' );                    // set database password
define( 'DB_NAME', 'yourdatabasename' );    // set database name

//include the class
include( 'src/class.visitorTracking.php' );

//instance the class
$visitors = new visitorTracking();

The constructor method automatically calls the tracking method $visitors->track(); which inserts the collected data.

You print the array containing the current visit by echoing $visitors->displayThisVisit();

You can output a table containing all the paginated data from the database by echoing $visitors->displayVisitors();

Alternatively, you can just grab the table data from your database SELECT * FROM visitors ORDER BY date DESC and format it according to your specifications.

License

This project is licensed under the MIT LICENSE

Contributors

Contributors on GitHub

Contributing

If you would like to help make this software better, please follow our guidelines found in CONTRIBUTING.md

Contact

  • Homepage: http://heshka.com
  • E-mail: tyler@heshka.com
  • KeyBase: https://keybase.io/theshka

  Visitor Tracking DemoExternal page  

Open in a separate window

Screenshots (1)  
  • Screenshot1
  Files folder image Files (159)  
File Role Description
Files folder imageexamples (1 file)
Files folder imageincludes (1 directory)
Accessible without login Plain text file index.php Example Displays the class
Accessible without login Plain text file LICENSE Data Auxiliary data
Accessible without login Plain text file README.md Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 99%
Total:1,161
This week:0
All time:3,267
This week:67Up
User Ratings User Comments (4)
 All time
Utility:76%StarStarStarStar
Consistency:75%StarStarStarStar
Documentation:-
Examples:67%StarStarStarStar
Tests:-
Videos:-
Overall:52%StarStarStar
Rank:2333
 
Class files is missing.
6 years ago (Matrix)
10%Star
there is no steps & library in folder
8 years ago (Brijesh Dhami)
0%Star
Does not work, because 2 database fields are missing.
10 years ago (manfred)
65%StarStarStarStar
great help traking users
10 years ago (Gerardo Rios RB)
80%StarStarStarStarStar