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 |
Messages In This Thread |
MeNeedz Visitor tracking - by El Forum - 01-24-2010, 05:49 PM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 03:30 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 03:50 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 04:40 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 05:09 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 05:15 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 05:20 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 05:28 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 05:33 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 05:54 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 06:00 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 06:45 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 06:54 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 06:59 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 07:08 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 07:19 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 09:41 AM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 05:20 PM
MeNeedz Visitor tracking - by El Forum - 01-25-2010, 05:22 PM
MeNeedz Visitor tracking - by El Forum - 01-26-2010, 01:02 AM
MeNeedz Visitor tracking - by El Forum - 01-26-2010, 04:10 AM
MeNeedz Visitor tracking - by El Forum - 01-26-2010, 04:41 AM
MeNeedz Visitor tracking - by El Forum - 01-26-2010, 04:55 AM
MeNeedz Visitor tracking - by El Forum - 01-27-2010, 04:54 PM
MeNeedz Visitor tracking - by El Forum - 02-18-2010, 05:22 AM
MeNeedz Visitor tracking - by El Forum - 02-18-2010, 05:31 AM
MeNeedz Visitor tracking - by El Forum - 02-18-2010, 05:57 AM
MeNeedz Visitor tracking - by El Forum - 02-18-2010, 11:23 AM
MeNeedz Visitor tracking - by El Forum - 03-02-2010, 10:51 AM
MeNeedz Visitor tracking - by El Forum - 09-18-2013, 04:04 PM
|