Welcome Guest, Not a member yet? Register   Sign In
How can I track users as they move through my site?
#1

[eluser]markanderson993[/eluser]
Hello there Codeigniter experts! I have a small question for you. You know how vBulletin forums display the number of guests and users online, and how you can click on that list and see what pages they are viewing? Is there any way I could possibly code a system similar to that for CodeIgniter?

Your responses are much appreciated, thank you Smile

- Pinoman993
#2

[eluser]davidbehler[/eluser]
You would have to do 2 things:
Update the user record and set the current time in a column like "last_action" or something like that whenever the user opens a site on your page and update another column called e.g. "last_place" where you save the last page he has visited.

Now you can select all users that have been online in the last 5min (or whatever time you want) by checking the last_action field. And for the page they are currently on, well just interpretate the last_place column.

You still have to work out the details but that's more or less what you have to do.
#3

[eluser]Tom Schlick[/eluser]
the way i do it is i make two tables. user_session_meta which includes all the browser, os, ip, etc information and assign the person a random key that also goes in that table. then i take that key and assign it to the session. then for each page the person goes to it writes that session key, the page uri, the referrer and the time to a table called user_page_visits.

im sure some other people have some other methods but i use that and it seems to work pretty well.
#4

[eluser]yelirekim[/eluser]
IMO the easiest thing to do would just be enable DB sessions and maybe extend the database class, you would really just have to attach one function to that, something like retrieve_active(), then take the active sessions and read out the userdata to get usernames. The Session class is already tracking the last time they loaded a page.

bottom of this page for a little more direction: http://ellislab.com/codeigniter/user-gui...sions.html

If you're a real stickler for DB efficiency you could also do this entire thing using just one SQL call after DB sessions are enabled.
#5

[eluser]Tom Schlick[/eluser]
yes that might work as long as you only want the data from right now and not have a record of it. if you want to be able to get the analytics data from say 3 hours ago then you would need to record it.
#6

[eluser]markanderson993[/eluser]
Thank you wald, yelirekim and trs you have been really informative Smile




Theme © iAndrew 2016 - Forum software by © MyBB