MeNeedz Visitor tracking |
[eluser]davidbehler[/eluser]
Recently I was wondering about the number of hits Google Analytics shows for one my pages (http://www.rapidseries.tv) and wrote my own small tracking script to count unique hits. At first it was really simple, insert a new entry into a database table for each unique combination of ip address, user agent and date and additionally to that saving the url the user was viewing and where he was coming from (referrer). But then I got more interested and wanted to make something more complex. I'm still working on it, but right now I can track a users movement upon my page and distinguish between bots and normal users and wether users come from a search engine (only checking for google right now) or from somewhere else. It's quite easy to use, only need to call one method to add a hit to the database. But let's start with the code first before we talk about using it: Right now there are two tables needed to make this work: Code: CREATE TABLE IF NOT EXISTS `visitor` ( Speaking of the model, you can download it from here: http://www.davidbehler.de/download/tracker_model.zip There are multiple ways for you to use this: If you have your own controller that all other controllers extend, e.g. MY_Controller, you can put it in the constructor: Code: function __construct() You can even have it all be done automatically by setting Code: var $auto_add_visit = TRUE; Code: $autoload['libraries'] = array('database', 'user_agent'); Right now there is only one function to help you analyse the collected data, but I'm working on more: Code: this->tracker_model->get_hits(); - $from_date: The begin of the period in Y-m-d format (defaults to yesterday - 1 month) - $to_date: The end of the period in Y-m-d format (defaults to yesterday) - $unique: Only show unique hits or not Examples Code: // #1 So tell me what you think. I thought this might be usefull David
[eluser]Sbioko[/eluser]
Thanks for a great contribution. But, it's too late for me. I done such library a few weeks ago :-) but, thanks!
[eluser]brianw1975[/eluser]
I've often thought about doing this, not because I wanted to target content or anything like that, i was just curious how people moved throughout my site. Can't wait to implement this and see how things go. Thanks!
[eluser]hugle[/eluser]
[quote author="waldmeister" date="1264398590"]Recently I was wondering about the number of hits Google Analytics shows for one my pages (http://www.rapidseries.tv) and wrote my own small tracking script to count unique hits. So tell me what you think. I thought this might be usefull David[/quote] I've done smth similar but with a lot less functionality earlier, but I see yours is full of functions I may need It will be very usefull, thank you please add it to your signature)) Thanks
[eluser]hugle[/eluser]
Code: // #2 You have a miss type here 2010-01-10 > 2010-01-01
[eluser]davidbehler[/eluser]
Miss type fixed I'll try to put it in my signature, but I'm afraid I'm running out of space
[eluser]hugle[/eluser]
[quote author="waldmeister" date="1264440007"]Miss type fixed I'll try to put it in my signature, but I'm afraid I'm running out of space [/quote] Imho you've forgot smth, topic title should be: MeNeedz Visitor Tracking )) thanks for good job
[eluser]Phil Sturgeon[/eluser]
Collecting this data isnt the hard part, its keeping it maintained well enough to stop your server exploding and still provide useful enough information. If you get a few thousand hits a day your database is gonna get big. |
Welcome Guest, Not a member yet? Register Sign In |