Current version: 0.2
InViewTracker is a lightweight JavaScript plugin useful for tracking how much time users spend viewing certain content on your web pages. News papers or blogs use InViewTracker to track how much time each user spends on reading articles on their website. Make sure all articles are within a container element (e.g. #article), include InViewTracker on your pages and start tracking!
InViewTracker should work in all modern browsers
I've tested InViewTracker on:
- Chrome 32+
- Firefox 28+
- IE 9+
- Safari for Windows 5.1+
Coming soon!
- element which element to track (default: ".article")
- pctInView percentage that the element must fill the screen to be "in view" (default: 50)
- eventHandler name of external function to handle event broadcasting
- heartbeatInterval interval (milliseconds) between heart beats (default: 2000 = 2 secs)
- heartbeatExpires how long (milliseconds) before heartbeat stops (default: 180000 = 3 mins)
- heartbeatTimeout how long (milliseconds) with inactivity before heartbeat stops (default: 30000 = 30 secs)
In the '''demo''' folder you can find various HTML pages to demo the plugin. Open the browsers console to view events.
- 0.2 Added property "heartbeatTimeout": used to ensure that InViewTracker does not calculate time spent in view when computer is left unattended (defaults to 30 seconds)
- 0.1 Initial release
Bug reports and code contributions are welcome. Please see CONTRIBUTIONS.md.
If you have any questions you can find me on Twitter at @olefrankjensen.
In making this plugin I was inspired by:
- Viljami S wrote a blog post about migrating from jQuery to Vanilla JavaScript. I used some of his suggestion how to decide when an element is in view.
- Addi Osmani wrote a great (free) book about JavaScript programming. I used the "Revealing Module Pattern" for my plugin 'cause it's just - nice!