I first though how the user interacts with our page: Each user starts a user session when he/she requests the web page files from the server for the first time. Once the first request is processed user get's back the first web page view. Then the user clicks a link on the web page and gets back from the server another page view. On each page view, we want to track what the user does: mouse clicks, key presses, ...With that in mind, I came up with a few requirements for the implementation:
an alternative to third party tracking tools
only pure/vanilla JS code (no external JS libraries)
support for new web browsers
track users that are not logged in
be able to track:
- number of views per page - what web site user came from - how long did the page take to load - type of user device and screen size - browser type - user language - time zone - page view durations - events during user page visit: clicks, key presses, ... - user sessions: what pages did the user visit sequentiallyWith the above list in mind, I started building things.
In the upcoming article, I'll focus on counting page visits and monitoring the necessary quantities. If you have any ideas, what else we could track let me know in the comment section below.