How to calculate the time spent in the Facebook application?

I want to track every user time spent in my Facebook application.

I really don't know how to do this, help me. If someone has any ideas or hints, this will be enough.

I am using the Graph API.

+6
php facebook facebook-graph-api
source share
3 answers

Or: Google Analytics

The simplest solution, of course, is to use Google Analytics - FBML (Facebook Markup Language) has a tag specifically for this: http://developers.facebook.com/docs/reference/fbml/google-analytics

This, of course, does not give you information about what a particular user did, but it’s nice to tell you the time spent on different pages of your Facebook application. And morally, it’s much better not to store what a specific user did on your site.

Or: Self-encoded solution

If you want to track everything you need, first you need to save when the page was accessed using PHP when the site was loading, and then with an interval of 10 seconds (or so) that the user is still present using an AJAX call. To do this, would I give the page a view of the id and send a request to a page like this * i_am_still_here.php? P = {page_view_id} *, which takes the current timestamp and updates the database entry for this pageview.

This solution has one problem: when a user opens a tab in the background and does not look at it for 30 minutes, you really do not want to store these 30 minutes as a "user on the site." In addition, make sure that with any self-encoded solution you choose, you must bear in mind that people can open your Facebook application in more than one tab.

+1
source share

Your problem is not related to Facebook as such. There are many ways to implement this, it also depends on your specific application.

You can track every click a user makes (timestamp of a click), and then calculate the time spent on it (the last click in a session is the first click in a session). This approach is not very accurate with the course, because you do not know how much time the user still used your application after the last click.

Another solution that comes to mind right now is to run an XHR (AJAX) request every X seconds, which will also write the timestamp in some storage (db, redis, memcache, ...), and then you can do that the same calculation from this. That would be more accurate (depending on your X interval).

0
source share

You can easily calculate the time spent on Facebook by downloading software called TimRabbit , which is a desktop application, and automatically calculates your time spent on facebook. It only calculates your time spent and ignores when you act as a simple user. See http://etechdiary.com/calculate-time-spent-on-facebook/ for more details.

-one
source share

All Articles