![]() |
Advice on what I should be looking at? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Advice on what I should be looking at? (/showthread.php?tid=65470) Pages:
1
2
|
Advice on what I should be looking at? - doomie22 - 06-15-2016 Hi there, I am starting to look into tracking people on my project and I am not sure if CI and php is able to track things like how long they are on a page or which page or should I be looking into JavaScript or something else? Any help or advice will be appreciated. Thanks, Doomie RE: Advice on what I should be looking at? - skunkbad - 06-15-2016 Google Analytics RE: Advice on what I should be looking at? - doomie22 - 06-15-2016 (06-15-2016, 07:58 AM)skunkbad Wrote: Google Analytics I want to make the analytics myself not have to have to go to multiple admin pages. RE: Advice on what I should be looking at? - albertleao - 06-15-2016 (06-15-2016, 08:02 AM)doomie22 Wrote:(06-15-2016, 07:58 AM)skunkbad Wrote: Google Analytics Google analytics is really the way to go. If you want your own dashboard, you can use google analytics and then connect with the api to get data I believe. If you're hellbent on rolling your own, which I advise against, you're going to have to write javascript on the frontend to track page loads, time on page, user ids and so on, and a backend service to receive all this data and store it appropriately. I guarantee you it will be inefficient, slow, and not scalable when compared to google analytics. RE: Advice on what I should be looking at? - arma7x - 06-15-2016 You can do this without using javascript, just collect and update the data from cookies. RE: Advice on what I should be looking at? - albertleao - 06-15-2016 (06-15-2016, 12:14 PM)arma7x Wrote: You can do this without using javascript, just collect and update the data from cookies. doomie22a said he wants to know how long they are on a page. While this can be done via cookies, it is much more efficient and accurate to track it via javascript functions RE: Advice on what I should be looking at? - arma7x - 07-01-2016 @alberdtleao, and if the javascript is disabled then how to handle this situation? @doomie22 this is not related to any documentation content, I'm just giving my opinion only. RE: Advice on what I should be looking at? - cartalot - 07-01-2016 you don't need javascript. you do need sessions. so lets say you make a db table called Users. and a table called UserPages. when the user first hits a web page - say its the home page - make a long randomized string to use as a 'token'. save that to the session. create your user in the db table, and use the Token as the unique ID. Get the page name - Home - and in your UserPages table - insert with the Token, the page name, and the current day time. Return the insert id, update your Users table with the id from UserPages in a field called something like last_page_visited, and a field for current day time. the user goes to page About - you pick up the token from the session - retrieve the user from the Users Table which includes the last visited Page Id. Look it up in the UserPages table, in a field for daytime left the page - update that record with the new time - and you can do a calculation for duration and put that in there as well. Insert the new page About with the daytime, and etc etc etc. Obviously theres a lot more you can record like their browser, ip, etc but that should give you the general idea and its pretty simple to do. also for those going omg google analytics --- theres a few million people using script blocker and it automatically blocks google analytics. RE: Advice on what I should be looking at? - arma7x - 07-01-2016 (07-01-2016, 05:17 PM)cartalot Wrote: you don't need javascript. you do need sessions. so lets say you make a db table called Users. and a table called UserPages. when the user first hits a web page - say its the home page - make a long randomized string to use as a 'token'. save that to the session. create your user in the db table, and use the Token as the unique ID.Totally agree with you, never trust client side since they can using scripy blocker. RE: Advice on what I should be looking at? - Diederik - 07-01-2016 Javascript has its downsides (can be disabled by client) it does have some advantages you can't get with PHP. PHP alone cant: - Measure the duration of last visited page. With PHP you only can determine the time difference between 2 visited pages. If you have some fancy 1 page website thats scrolls alot you cant measure any visited times at all. - Detect screen size of the client I have spend many and many hours creating my own PHP based statistics in the past because I don't like Google's ambition to know everything from everyone. But it always felt the results came up (very) short compared to Google Analytics. Since more and more clients wanted better statics I sadly decided just to give up on my own project. I still don't use Google on my own website but I do for all my clients. It saves a lot of hassle ;-) If you don't want to give Google any more data you can use Piwik, an excellent self hosted alternative. |