• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Advice on what I should be looking at?

#1
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
Reply

#2
Google Analytics
Reply

#3
(06-15-2016, 08:58 AM)skunkbad Wrote: Google Analytics

I want to make the analytics myself not have to have to go to multiple admin pages.
Reply

#4
(06-15-2016, 09:02 AM)doomie22 Wrote:
(06-15-2016, 08:58 AM)skunkbad Wrote: Google Analytics

I want to make the analytics myself not have to have to go to multiple admin pages.

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.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply

#5
You can do this without using javascript, just collect and update the data from cookies.
Keep calm.
Reply

#6
(06-15-2016, 01: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
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply

#7
@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.
Keep calm.
Reply

#8
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.
Reply

#9
(07-01-2016, 06: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.

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.
Totally agree with you, never trust client side since they can using scripy blocker.
Keep calm.
Reply

#10
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.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.