This module tracks, by Ajax, how long a registered user took to read a page.
You can configure which content type and role should be tracked and view the report, exhibiting the total hours (or minutes/seconds) a user spent reading a page. The interval between one Ajax call and other can be configurable trough UI also.
There isn't any module dependency.
USE CASE:
You need to track and exhibit a statistic report with the amount of time a registered user took reading a node page.
LIMITATIONS:
- This module only tracks node pages and registered users. Taxonomy or views pages aren't tracked, but can be in later versions.
- If you need to track anonymous visits, consider using Google Analytics (GA can't track registered users by its privacy terms).
RECOMMENDATIONS:
Session Aggregator can track the total time a user has spent on the site.
Automated Logout provides a site administrator the ability to log users out after a specified time of inactivity.
Session Limit allows administrators to limit the number of simultaneous sessions per user.
Obs.: These modules aren't required, but if you need to track the amount of time a user spent, probably you'll like them also.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | user_time_page.zip | 4.5 KB | carvalhar |
| user_time_page.zip | 3.78 KB | carvalhar |
Comments
Comment #0.0
carvalhar commentedforgot
Comment #1
berkas1 commentedYou have to post a link to your sandbox project to review
Comment #2
carvalhar commentedok. sandbox: http://drupal.org/sandbox/carvalhar/1255040
Comment #2.0
carvalhar commentedmissing closing tag
Comment #3
carvalhar commentedadding a newer version already.
Now there's a configurable LIMIT variable between the Ajax calls.
Comment #4
carvalhar commentedToday, I added a new function (track time spent on the entire site) and uploaded to the sandbox git.
Added some screenshots also:
http://carvalhar.com/componente/drupal/time_spent/index.html
I hope to be approved ;)
Comment #5
attiks commentedI did a quick Coder review to check the Coding Standards, see below.
Severity minor, Drupal Commenting Standards, Drupal Security Checks, Drupal SQL Standards, Drupal Coding Standards, Internationalization
sites/all/modules/time_spent/time_spent.module:
+4: [minor] There should be no trailing spaces
+7: [minor] There should be no trailing spaces
+23: [normal] Menu item titles and descriptions should NOT be enclosed within t().
+24: [normal] Menu item titles and descriptions should NOT be enclosed within t().
+31: [normal] Menu item titles and descriptions should NOT be enclosed within t().
+32: [normal] Menu item titles and descriptions should NOT be enclosed within t().
+50: [normal] Use an indent of 2 spaces, with no tabs
+56: [normal] Use an indent of 2 spaces, with no tabs
+57: [normal] Use an indent of 2 spaces, with no tabs
+58: [normal] Use an indent of 2 spaces, with no tabs
+58: [minor] There should be no trailing spaces
+59: [normal] Use an indent of 2 spaces, with no tabs
+59: [minor] There should be no trailing spaces
+60: [normal] Use an indent of 2 spaces, with no tabs
+61: [normal] Use an indent of 2 spaces, with no tabs
+62: [normal] Use an indent of 2 spaces, with no tabs
+63: [normal] Use an indent of 2 spaces, with no tabs
+63: [minor] There should be no trailing spaces
+64: [normal] Use an indent of 2 spaces, with no tabs
+65: [normal] Use an indent of 2 spaces, with no tabs
+66: [normal] Use an indent of 2 spaces, with no tabs
+66: [normal] use a space between the closing parenthesis and the open bracket
+66: [minor] There should be no trailing spaces
+67: [normal] Use an indent of 2 spaces, with no tabs
+68: [normal] Use an indent of 2 spaces, with no tabs
+69: [normal] Use an indent of 2 spaces, with no tabs
+70: [normal] Use an indent of 2 spaces, with no tabs
+71: [normal] Use an indent of 2 spaces, with no tabs
+71: [normal] missing space after comma
+92: [normal] Use an indent of 2 spaces, with no tabs
+99: [normal] Use an indent of 2 spaces, with no tabs
+105: [normal] Use an indent of 2 spaces, with no tabs
+111: [normal] Use an indent of 2 spaces, with no tabs
+112: [normal] Use an indent of 2 spaces, with no tabs
+113: [normal] Use an indent of 2 spaces, with no tabs
+114: [normal] Use an indent of 2 spaces, with no tabs
+115: [critical] table names should be enclosed in {curly_brackets}
+115: [normal] Use an indent of 2 spaces, with no tabs
+115: [minor] There should be no trailing spaces
+116: [critical] table names should be enclosed in {curly_brackets}
+116: [normal] Use an indent of 2 spaces, with no tabs
+117: [normal] Use an indent of 2 spaces, with no tabs
+117: [minor] There should be no trailing spaces
+118: [normal] Use an indent of 2 spaces, with no tabs
+119: [normal] Use an indent of 2 spaces, with no tabs
+120: [normal] Use an indent of 2 spaces, with no tabs
+121: [normal] Use an indent of 2 spaces, with no tabs
+121: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
+122: [normal] Use an indent of 2 spaces, with no tabs
+122: [normal] Functions should be called with no spaces between the function name and opening parentheses
+123: [normal] Use an indent of 2 spaces, with no tabs
+124: [normal] Use an indent of 2 spaces, with no tabs
+125: [normal] Use an indent of 2 spaces, with no tabs
+126: [normal] Use an indent of 2 spaces, with no tabs
+127: [normal] Use an indent of 2 spaces, with no tabs
+128: [normal] Use an indent of 2 spaces, with no tabs
+128: [minor] There should be no trailing spaces
+129: [normal] Use an indent of 2 spaces, with no tabs
+130: [normal] Use an indent of 2 spaces, with no tabs
+131: [normal] Use an indent of 2 spaces, with no tabs
+132: [critical] table names should be enclosed in {curly_brackets}
+132: [normal] Use an indent of 2 spaces, with no tabs
+132: [minor] There should be no trailing spaces
+133: [critical] table names should be enclosed in {curly_brackets}
+133: [normal] Use an indent of 2 spaces, with no tabs
+134: [normal] Use an indent of 2 spaces, with no tabs
+134: [minor] There should be no trailing spaces
+135: [normal] Use an indent of 2 spaces, with no tabs
+136: [normal] Use an indent of 2 spaces, with no tabs
+137: [normal] Use an indent of 2 spaces, with no tabs
+137: [minor] in most cases, replace the string function with the drupal_ equivalent string functions
+138: [normal] Use an indent of 2 spaces, with no tabs
+138: [normal] Functions should be called with no spaces between the function name and opening parentheses
+139: [normal] Use an indent of 2 spaces, with no tabs
+140: [normal] Use an indent of 2 spaces, with no tabs
+141: [normal] Use an indent of 2 spaces, with no tabs
+142: [normal] Use an indent of 2 spaces, with no tabs
+143: [normal] Use an indent of 2 spaces, with no tabs
+144: [normal] Use an indent of 2 spaces, with no tabs
+144: [minor] There should be no trailing spaces
+145: [normal] Use an indent of 2 spaces, with no tabs
+149: [normal] Use an indent of 2 spaces, with no tabs
+150: [normal] Use an indent of 2 spaces, with no tabs
+151: [normal] Use an indent of 2 spaces, with no tabs
+152: [critical] table names should be enclosed in {curly_brackets}
+152: [normal] Use an indent of 2 spaces, with no tabs
+152: [normal] string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms
+153: [normal] Use an indent of 2 spaces, with no tabs
+154: [normal] Use an indent of 2 spaces, with no tabs
+154: [minor] There should be no trailing spaces
+155: [critical] table names should be enclosed in {curly_brackets}
+155: [normal] Use an indent of 2 spaces, with no tabs
+155: [normal] string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms
+156: [normal] Use an indent of 2 spaces, with no tabs
+157: [normal] Use an indent of 2 spaces, with no tabs
+158: [normal] Use an indent of 2 spaces, with no tabs
+158: [minor] There should be no trailing spaces
+159: [normal] Use an indent of 2 spaces, with no tabs
+160: [normal] Use an indent of 2 spaces, with no tabs
+161: [normal] Use an indent of 2 spaces, with no tabs
+162: [normal] Use an indent of 2 spaces, with no tabs
+163: [normal] Use an indent of 2 spaces, with no tabs
+163: [minor] There should be no trailing spaces
+164: [normal] Use an indent of 2 spaces, with no tabs
+165: [normal] Use an indent of 2 spaces, with no tabs
+166: [normal] Use an indent of 2 spaces, with no tabs
+167: [normal] Use an indent of 2 spaces, with no tabs
+168: [normal] Use an indent of 2 spaces, with no tabs
+169: [critical] table names should be enclosed in {curly_brackets}
+169: [normal] Use an indent of 2 spaces, with no tabs
+169: [normal] string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms
+170: [normal] Use an indent of 2 spaces, with no tabs
+171: [normal] Use an indent of 2 spaces, with no tabs
+172: [critical] table names should be enclosed in {curly_brackets}
+172: [normal] Use an indent of 2 spaces, with no tabs
+172: [normal] string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms
+173: [normal] Use an indent of 2 spaces, with no tabs
+174: [normal] Use an indent of 2 spaces, with no tabs
+175: [normal] Use an indent of 2 spaces, with no tabs
+176: [normal] Use an indent of 2 spaces, with no tabs
+177: [normal] Use an indent of 2 spaces, with no tabs
+178: [normal] Use an indent of 2 spaces, with no tabs
+179: [normal] Use an indent of 2 spaces, with no tabs
+180: [normal] Use an indent of 2 spaces, with no tabs
+181: [normal] Use an indent of 2 spaces, with no tabs
+181: [minor] There should be no trailing spaces
+182: [normal] Use an indent of 2 spaces, with no tabs
+185: [normal] Functions should be called with no spaces between the function name and opening parentheses
+185: [normal] Use uppercase for PHP constants, e.g. NULL, TRUE, FALSE
+186: [minor] There should be no trailing spaces
+187: [minor] There should be no trailing spaces
+188: [minor] There should be no trailing spaces
+189: [normal] string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms
+190: [normal] string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms
+190: [minor] There should be no trailing spaces
+191: [minor] There should be no trailing spaces
+192: [normal] string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms
+193: [minor] There should be no trailing spaces
+195: [minor] There should be no trailing spaces
+201: [normal] Use an indent of 2 spaces, with no tabs
+206: [normal] Use an indent of 2 spaces, with no tabs
+206: [minor] There should be no trailing spaces
+207: [normal] Use an indent of 2 spaces, with no tabs
+207: [minor] There should be no trailing spaces
+210: [normal] Use an indent of 2 spaces, with no tabs
+211: [normal] Use an indent of 2 spaces, with no tabs
+212: [normal] Use an indent of 2 spaces, with no tabs
sites/all/modules/time_spent/time_spent.install:
+-1: [normal] @file block missing
+22: [normal] Use an indent of 2 spaces, with no tabs
+34: [normal] Use an indent of 2 spaces, with no tabs
+49: [normal] Use an indent of 2 spaces, with no tabs
+49: [minor] There should be no trailing spaces
+50: [normal] Use an indent of 2 spaces, with no tabs
+64: [normal] Use an indent of 2 spaces, with no tabs
sites/all/modules/time_spent/time_spent.js:
No Problems Found
Status Messages:
Coder found 1 projects, 3 files, 8 critical warnings, 118 normal warnings, 28 minor warnings, 0 warnings were flagged to be ignored
Comment #6
carvalhar commentedok, i sent by git the fixed files.
Is everything ok now?
thanks
Comment #7
carvalhar commentedchanging status
Comment #8
attiks commentedGood work, I had a closer look at the code
1/ inside time_spent_init you better use menu_get_object, it return you the node if you're on a node page
2/ the comment on line 153 should read //monitors the time user spent on the site
3/ people can fool the system, if a open time_spent/1 and hit refresh a couple of times, the system will think i was on node/1 for a couple of minutes
Comment #9
attiks commentedComment #10
carvalhar commentedHi,
I'm using now menu_get_object.
About #3, yes, that's true.
User can fool the system if he discover the ajax url. But at first, he needs to know that he's being monitored and discover how this is happening (someone with javascript knowledge can discover by firebug kind easy although).
I think i can pass to ajax a hash made with session id and drupal key and the time the server send minus the timer settings. But it's not simple...I can't imagine a simple way to do this...Do you have any idea?
Right now, I'll let this as a future thing to fix.
Is everything ok?
thanks
Comment #11
attiks commentedThere are some minor trailing white spaces and indentation problems
The following code is 'strange', and the function needs better indentation
you can not expect end users to change your module, so I see 2 options:
a/ remove the comment and explain in the readme file
b/ just use hook_init, it normally will fire for each request for non-anon users, so remove the comment
Comment #12
carvalhar commentedok, removed the comment and edited the README.txt
git done. everything up-to-date.
Comment #13
attiks commentedLast round, almost there
time_spent.install:
lines 48-50: you may remove these, primary key is unique
lines 76-78: you may remove these, primary key is unique
also check the indentation
time_spent.js:
6-9: just remove it, add it later when it's implemented
15-16: better remove all code in comment
time_spent.module:
+4: [minor] There should be no trailing spaces
+7: [minor] There should be no trailing spaces
+61: [minor] There should be no trailing spaces
+113: [minor] There should be no trailing spaces
+115: [minor] There should be no trailing spaces
+127: [minor] There should be no trailing spaces
+131: [minor] There should be no trailing spaces
+133: [minor] There should be no trailing spaces
+143: [minor] There should be no trailing spaces
+145: [critical] Potential problem: "SELECT FROM {node}" statements should probably be wrapped in db_rewrite_sql() and with the alias for {node} table defined (e.g. {node} n)
+153: [minor] There should be no trailing spaces
+157: [minor] There should be no trailing spaces
+162: [minor] There should be no trailing spaces
+180: [minor] There should be no trailing spaces
+185: [minor] There should be no trailing spaces
+186: [minor] There should be no trailing spaces
+187: [minor] There should be no trailing spaces
+189: [minor] There should be no trailing spaces
+190: [minor] There should be no trailing spaces
+192: [minor] There should be no trailing spaces
+194: [minor] There should be no trailing spaces
+205: [minor] There should be no trailing spaces
the remark about line 145, is about
should be something like this
Always try to use ' instead of "
Comment #14
carvalhar commentedok thanks.
revised and commited to GIT.
Comment #15
attiks commentedcode looks good to me
Comment #16
tim.plunkett#1255774: [D6] Share Stats
Comment #16.0
tim.plunkettsandbox
Comment #17
avpaderno