Jump to content

SiteStats


onlyican

Recommended Posts

Hey guys

I have a small problem

What I want to do is Record movement on my website

For example
When a user clicks on the website I want to log
What time they came on the website
What page they are on
There IP
Where they come from

But for every user, every page
so I can see that a user clicked on 10 pages before closing or something

I was thinking of adding into a MySQL table
But then if you look at a basic screen of
100 Unique Hits a day
say
3000 Page Hits

Thats a lot of data to add into a table

thats 21000 entries per week

OR
90000 entries on a 30 day month

So what is the best way of storing all this data without killing the server by filling up a MySQL table
Link to comment
Share on other sites

Create a table, and log the users IP.

Insert their IP into the table, and have something like:

IP | Hits | Time | LastPage

And check if the user's IP already exists in the database, and if it does then it won't create a new row each time. Then just do

[code]
$sql = "SELECT ip FROM stats WHERE ip ='$_SERVER[REMOTE_ADDR]'";
$res = mysql_query($sql);
$res2 = mysql_fetch_assoc($res);
$num = mysql_numrows($res);

if($num > 0){
//update stats
}else {
$sql = "INSERT INTO stats (`ip`) VALUES('$_SERVER[REMOTE_ADDR]')";
$res = mysql_query($sql);
};
[/code]
Link to comment
Share on other sites

I dont want to use it in the code in that way, cos I would use sessions for last page

I want to be able to run a query
Find out when a user came on the site, where he came from, what link he then clicked on, then after that, how long was he on each page

(Sorry bout using he, it could be a she as well)
Link to comment
Share on other sites

Your best solution would actually using a different row for each one.

Or you can create a table for each IP, but that would be ever worse, haha. I understand what you're saying, and your first theory with over 90,000 rows, yes that would be alot, like only 30-60mb of SQL usage.
Link to comment
Share on other sites

A bit similar, but check out [url=http://www.google.com/analytics]Google's Analytics[/url] Not that it will show you how its coded, but its a free service that Google offers that tracks site information.

Google bought out Urchin so its similar to one of the more popular sitetracking applications out there.

Just an idea.. that's all.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.