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.
Sebastian
source share