A-STYLEDESIGN…the Freelancer

3D Artist online portfolio

Take a look at my works in fields of
-Architectural Visualization
-Lowpoly Modeling
-3D Interactive Presentation
-Graphic Design

read more...

-3D Architectural Visualization
-2D/3D Floorplan
-3D Lowpoly Modeling
-3D Interactive Presentation
-Graphic Design

read more...

-Learn design from the bests,
-Books,tutorials
-Download 3D models
-2D furniture packs for Architectural Illustrations

read more...

Free 3D Wallpapers:
-3D Car Wallpapers
-Fantasy Wallpapers
-Space Wallpapers
In resolution of 1680x1050px

read more...


“Number of pageloads” visitor tracking script

When we create a website and put into service, we would like to know how many visitors do we have, which pages they looked at, or how many times have been some files downloaded. Therefore we’re using so-called visitor trackers.
Problems with tracking begin when the visitors disable cookies or they don’t have fixed IP’s (which is the case in many instances). 99% of the visitor trackers use cookies to record visits. Statistics show that 35% of the surfers disable cookies, and only in certain cases – when they want to register – allow them. In this case, the cookie-based visitor tracker works with 35% of mistake.

I’ve recently found a php script that doesn’t use cookies for tracking page visitors, but instead it completely relies on MySql database.

Here is the code listing:

// PHP SCRIPT FOR DISPLAYING NUMBER OF UNIQUE VISITS OF A PARTICULAR PHP PAGE WITHOUT COOKIES
// Written by : Victor Dujmovic – copyright – 03/09/2009
// http://www.blogofd.com
// dujmovicv@gmail.com
// skype : dujmovicv
// msn : blogofd@hotmail.com

$query_loads  = “SELECT * from visited_stuff WHERE username = ‘$session->username’ AND stuff_id = ‘$this_id’
ORDER by id ASC”;
$result_loads = mysql_query($query_loads) or die(’Error : ‘ . mysql_error());
$num_loads    = mysql_num_rows($result_loads);

$username = $session->username;
$today = date(’Ymd’);
$this_day = (int)$today;

if ($num_loads == 0 and $this_id != 0)
{
$query_update = “INSERT INTO visited_stuff SET
stuff_id = ‘$this_id’,
username = ‘$username’,
visited = ‘$today’,
nr_visits = 1 “;

mysql_query($query_update) or die(’Error, query failed. ‘ . mysql_error());
}

// GET NUMBER OF PAGELOADS

$query_nr_loads  = “SELECT * from visited_stuff WHERE username = ‘$session->username’ AND stuff_id = ‘$this_id’
ORDER by id ASC”;
$result_nr_loads = mysql_query($query_nr_loads) or die(’Error : ‘ . mysql_error());

while($row_nr_loads = mysql_fetch_array($result_nr_loads))
{
$that_day = (int)$row_nr_loads['visited'];
$nr_visits = $row_nr_loads['nr_visits'];

if ($this_day != $that_day)
{
$new_nr_visits = $nr_visits + 1;

$query_loads = “UPDATE visited_stuff SET
visited = ‘$today’,
nr_visits = ‘$new_nr_visits’
WHERE username = ‘$session->username’ AND stuff_id = ‘$this_id’ “;

mysql_query($query_loads) or die(’Error, query failed. ‘ . mysql_error());
}

if ($this_day == $that_day and $session->username == “guest”)
{
$new_nr_visits = $nr_visits + 1;

$query_loads = “UPDATE visited_stuff SET
visited = ‘$today’,
nr_visits = ‘$new_nr_visits’
WHERE username = ‘$session->username’ AND stuff_id = ‘$this_id’ “;

mysql_query($query_loads) or die(’Error, query failed. ‘ . mysql_error());
}

}

// END NUMBER OF PAGELOADS

The script can be easily adjusted to use a plain text file instead of a database – for users who doesn’t have database support on their servers. Visitor tracking becomes very simple this way and is independent from the users’ browser configuration (cookies) and from their IP addresses as well.

The mentioned script – in its current version – is counting only the internal links (links pointing at pages on the same server/domain). I’ve contacted the writer of the script, and hopefully an improved version will be released soon which will be able to track external links as well. The real potential of the script however will rise to surface when a Wordpress plugin with an admin panel will be released.

Writer of the script is Viktor Dujmovic, founder of D-Sign Responder and a freelance programmer who is dedicated mostly to developing various php scripts (like Content Management Systems, automated e-mail management software, web directory- and community scripts, etc.), website design, furthermore he is configuring Linux-based servers as well.

Bookmark and Share

Random Posts

Tagged as: , , ,

Leave a Response

Please note: comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Security Code: