PHP如何通过网站跟踪用户的导航路径

So we plan to track a user's activity within our website which are in PHP. What we want to know is track a unique session for a user from the time he first visits a page in our site, the pages he visited next, and visited last.

Some kind of tracking his footprint through our site. We actually have identified 2 methods, one is using a custom code, and the other is analytics.js.

We find analytics.js too much for this (and my take more time to setup including time for our Internal Team to familiarize/learn the tool). Considering what we need is just getting the timelogs of the user's session.

So we'll be going with a custom code added to each of the pages that need tracking. This script will do the follow:

  • we will be pasting code snippets to pages that need tracking
  • generate a unique session ID once he lands on any of the tracked pages
  • records the activity on a database
  • create an admin dashboard to visualize each of the user's activity, just a simple UI to showing the timelogs and pages visited

That's our plan so just wondering if the above is acceptable, or if there's any other easier way to do it?

Thanks in advance StackOverflow community!