PHP Traffic Tracker...?
Discussion
Whilst as I fancy writing my own as well (it'd be easy in reality), www.statcounter.com has one already which is fairly proficent.
docevi1 said:
Whilst as I fancy writing my own as well (it'd be easy in reality), www.statcounter.com has one already which is fairly proficent.
Thanks for the quick response
, but sadly I have an enormous amount of web traffic and wouldn't qualify for the free version. Plus, I need detailed info regarding every unique visitor visiting, or more importantly, leaving the site.Depends exactly what you want to track, and how you want to present the data you generate.
To show where they enter and where they leave isn’t too bad and most stats programs, like the suggested AWstats will show all this.
Also, try Google Analytics – there may still be a waiting list though.
You can also look at SawMill, it analyses most log files. www.sawmill.net/
If you want to make your own, here’s one simple method (psudo code):
include(stats.php) – stick this on every page of the site
make a script called stats.php, that does the following:
if (visitor id cookie does not exist) {
create new visitor id (last id +1)
}
save visitor id in cookie with expiry of say 15 minutes
// refreshes the cookie or creates it if its not there already
now insert into your site database’s stats table the visitor id, datetime stamp, page name ($_SERVER['PHP_SELF']; ), and any tracking variables your using (such as “$ad” )
You can use tracking variables on your links from adverts such as yourdomain.com/product_info.php?ad=googleadsense9 – don’t use them for all links as I believe they reduce the links weight when it comes to SEO, but that’s another story. If you’re paying for clicks or banner placement, use a tracking URL with a variable to indicate which advert it came from.
This gives you a simple log of every page visited with most page impressions linked to a visitor, thus crude way of tracking user browsing on your site. You could alternatively create a session if one doesn’t already exist, then use that session id to link the page impression to a user session.
With your raw data you can quite easily establish which page they entered the site on, which page they left the site on (the last page viewed for that visitor/session id) and how many pages they looked at, how long they spent between pages, and produce a history showing their browsing.
Most bots don’t accept cookies, so you could either test cookie acceptance then only log page impressions for visitors that do, or you could assume every visitor id with only one page impression is either a bot or doesn’t need to be considered. You could go a step further by looking at the browser type and logging that, and/or filtering so you only track known web browsers, ignoring spiders and other bots.
You can expand it further by creating a second longer lasting session/visitor id that is set to last for months on the users computer. This will let you see when people come back – as they will have different visitor ids, yet the longer lasting id will be the same as long as they didn’t delete the cookie.
To show where they enter and where they leave isn’t too bad and most stats programs, like the suggested AWstats will show all this.
Also, try Google Analytics – there may still be a waiting list though.
You can also look at SawMill, it analyses most log files. www.sawmill.net/
If you want to make your own, here’s one simple method (psudo code):
include(stats.php) – stick this on every page of the site
make a script called stats.php, that does the following:
if (visitor id cookie does not exist) {
create new visitor id (last id +1)
}
save visitor id in cookie with expiry of say 15 minutes
// refreshes the cookie or creates it if its not there already
now insert into your site database’s stats table the visitor id, datetime stamp, page name ($_SERVER['PHP_SELF']; ), and any tracking variables your using (such as “$ad” )
You can use tracking variables on your links from adverts such as yourdomain.com/product_info.php?ad=googleadsense9 – don’t use them for all links as I believe they reduce the links weight when it comes to SEO, but that’s another story. If you’re paying for clicks or banner placement, use a tracking URL with a variable to indicate which advert it came from.
This gives you a simple log of every page visited with most page impressions linked to a visitor, thus crude way of tracking user browsing on your site. You could alternatively create a session if one doesn’t already exist, then use that session id to link the page impression to a user session.
With your raw data you can quite easily establish which page they entered the site on, which page they left the site on (the last page viewed for that visitor/session id) and how many pages they looked at, how long they spent between pages, and produce a history showing their browsing.
Most bots don’t accept cookies, so you could either test cookie acceptance then only log page impressions for visitors that do, or you could assume every visitor id with only one page impression is either a bot or doesn’t need to be considered. You could go a step further by looking at the browser type and logging that, and/or filtering so you only track known web browsers, ignoring spiders and other bots.
You can expand it further by creating a second longer lasting session/visitor id that is set to last for months on the users computer. This will let you see when people come back – as they will have different visitor ids, yet the longer lasting id will be the same as long as they didn’t delete the cookie.
Edited by s a m on Monday 5th June 00:12
It doesn't need to be a php tracker - as long as your web server creates W3C compliant log files you can use any number of log file analysis tools. I've used "weblog expert" which is pretty good, and can monitor entry, exit and pathways through your site. There is a free version as well.
Otherwise get signed up for google analytics, it's pretty groovy.
Google Analytics:
Weblog Expert:
Otherwise get signed up for google analytics, it's pretty groovy.
Google Analytics:
Weblog Expert:
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff



