Re: Showing which users are viewing a given page
On 04/03/2014 13:06, Paul J Stevens wrote: On 04-03-14 13:28, Some Developer wrote: Hopefully someone here will be able to point me in the right direction. Basically I want to be able to view which users are viewing a page at any given time and I want to be able to update it in real time using JavaScript but I'm at a loss as to how to track which users are viewing any given page in Django. So enter some long-polling javascript that notifies the server every X seconds that some user is still at the page you're tracking. So for instance if I had mydomain.com/page/ I'd like a little box on the top of the page saying "Page being viewed by users: xxx and yyy" and then when one of those users navigates away from the page the box updates to remove that user from the list. This means that apart from the "I'm still here", you also need a "Who's here at" as well. I'm not sure if I have described what I want clearly enough so if you need any more information let me know. Any help is appreciated :). So for each page you want to track: use a settimeout loop in javascript to: - do a POST to some mini-view where you register who's at some page. You can use the REMOTEUSER (auth-user) to find out who's who, and the Referer header to see where they are in your site. - this POST returns some data (json?) that will tell you who else is there. You can now update your DOM to reflect this information. If you don't want or care about authenticating users, you can't know who is actually at the page, just the number of people, and their IP addresses, browser version, etc. Of course some people have done this before. Maybe check out TogetherJS for more real-time collaboration goodies. Thank you for the information; it is helpful. Along with the other tips here (I hadn't thought of using socket.io which looks really useful) I should be able to hack something together to get this working. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5316FDA8.3010105%40googlemail.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Showing which users are viewing a given page
Hey Some Developer, If you have the option, try http://www.google.com/analytics/. There are other similar services to get the analytics about real time usage statistics about your website. If you want to identify each individual user, http://kissmetrics.com/ or https://mixpanel.com/ are also good bets. Actually you can do this even in google analytics with a bit of customization. Hope it helps. Regards, Some other developer -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/01646285-d61e-4d84-8a47-d6177f5f8aae%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Showing which users are viewing a given page
On 04-03-14 13:28, Some Developer wrote: > Hopefully someone here will be able to point me in the right direction. > > Basically I want to be able to view which users are viewing a page at > any given time and I want to be able to update it in real time using > JavaScript but I'm at a loss as to how to track which users are viewing > any given page in Django. So enter some long-polling javascript that notifies the server every X seconds that some user is still at the page you're tracking. > So for instance if I had mydomain.com/page/ I'd like a little box on the > top of the page saying "Page being viewed by users: xxx and yyy" and > then when one of those users navigates away from the page the box > updates to remove that user from the list. This means that apart from the "I'm still here", you also need a "Who's here at" as well. > I'm not sure if I have described what I want clearly enough so if you > need any more information let me know. Any help is appreciated :). So for each page you want to track: use a settimeout loop in javascript to: - do a POST to some mini-view where you register who's at some page. You can use the REMOTEUSER (auth-user) to find out who's who, and the Referer header to see where they are in your site. - this POST returns some data (json?) that will tell you who else is there. You can now update your DOM to reflect this information. If you don't want or care about authenticating users, you can't know who is actually at the page, just the number of people, and their IP addresses, browser version, etc. Of course some people have done this before. Maybe check out TogetherJS for more real-time collaboration goodies. -- Paul J Stevens pjstevns @ gmail, twitter, github, linkedin www.nfg.nl/i...@nfg.nl/+31.85.877.99.97 -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5315CFCB.2040907%40nfg.nl. For more options, visit https://groups.google.com/groups/opt_out.
Re: Showing which users are viewing a given page
my opinion, frontend: setup a ping api, and refresh every 30 seconds, pass in a current page url from javascript, and return current page viewers. backup: a table has 3 main column (user id, page id, last_ping). update the page_id and last_ping when receiving a ping request. and return users list who are on the same page and last_ping within 60 seconds. 30 or 60 seconds are sample data. Regards, Dig 2014-3-4 下午8:30于 "Some Developer" 写道: > Hopefully someone here will be able to point me in the right direction. > > Basically I want to be able to view which users are viewing a page at any > given time and I want to be able to update it in real time using JavaScript > but I'm at a loss as to how to track which users are viewing any given page > in Django. > > So for instance if I had mydomain.com/page/ I'd like a little box on the > top of the page saying "Page being viewed by users: xxx and yyy" and then > when one of those users navigates away from the page the box updates to > remove that user from the list. > > I'm not sure if I have described what I want clearly enough so if you need > any more information let me know. Any help is appreciated :). > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/django-users/5315C6F8.10701%40googlemail.com. > For more options, visit https://groups.google.com/groups/opt_out. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAObE2pED60iprTzivr--LQv_yVPcverJurnJ8EPE9MEpXOq1MQ%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: Showing which users are viewing a given page
Well proper way of doing that in your case would be to use something like a socket.io and have each page as a separate channel. Than you can on user join/leave emit/push appropriate count. Other way would be to hook on middleware http request and than update or redis or database entry for that particular "page". Once you have that you can long poll from javascript to update count. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAD1DFf0cN0xffQ4SOikn13vxj%2BrCdWVi%2B395-9f1vEt-er%2Br2Q%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Showing which users are viewing a given page
Hopefully someone here will be able to point me in the right direction. Basically I want to be able to view which users are viewing a page at any given time and I want to be able to update it in real time using JavaScript but I'm at a loss as to how to track which users are viewing any given page in Django. So for instance if I had mydomain.com/page/ I'd like a little box on the top of the page saying "Page being viewed by users: xxx and yyy" and then when one of those users navigates away from the page the box updates to remove that user from the list. I'm not sure if I have described what I want clearly enough so if you need any more information let me know. Any help is appreciated :). -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5315C6F8.10701%40googlemail.com. For more options, visit https://groups.google.com/groups/opt_out.