Tracking User movements

Does anyone track user movements and if so what do you set up? This is for an internal administration system.

From simple recording of when a user logs in
through to

  • which pages they visit?
  • which forms and buttons they press?
  • which form fields did they fill in and with what information?

This could be a massive undertaking in itself. I don’t want to make it too complicated yet I need the information to be usable.

My reasoning is to have a basic audit trail of who did what and have that viewable as on-screen reports. There may be 2 reports…

  1. What did User A do today? And which projects did they work on?
  2. Who worked on Project B3 and in what areas of the project?

I am looking for ideas/suggestions.

We just have a simple activity table. We grab the user uid from a session set when they log-in.

id
usrUID
dateTime
activityDetail

On every action (CRUD) we have an activity insert in to this table. So there will be the actual action of the CRUD and afterwards the insert in to the activity table, the activityDetail is just entered as a brief description, ie, deleted this, added that, etc. Works well for general activity, like such:

Simple but useful metrics.

1 Like

I like that @Dave, as you say, it’s simple. Probably simpler than we were planning but maybe we can consider this, thanks.

2 Likes

Makes for pretty charts too Neil (activity grouped by day for the last thirty days) then we drill down from here…

1 Like

Why you grab UID session instead of using Security Identity component?

No real reason. Out of habit really, and some of the older legacy systems of this client use this data for other things Some further details are sent and recorded for other purposes. Really depends on what kind of activity and what caliber of user.

1 Like

We like pretty pictures! :smile:

1 Like

So many tools out there for this if you don’t want to build it yourself.

Amplitude has a nice free tier, Google analytics plus Google tag manager, too.

We use Segment.com for tracking all user actions and then pass the data to different destinations.

on each API Action insert into an audit table the post/get body of the API call - this will help you capture each step they take on the app.
the API call body will be JSON - to be able to use that data you should on a DB that supports JSON like MySQL 8+ or PostgreSQL.
given that it is an internal app, each page will have some dynamic data coming in via an API Actions - so this setup should work.
Also, you may want to create a library action to insert in audit logs table and use that library action elsewhere - to keep the insert action centralised in one place will allow for easier way to make changes.

3 Likes

That's exactly what I do. Makes it very easy to add it to all the API scripts and get a consistent set of data in the activity table.

1 Like

Hi @nshkrsh, sorry but only just getting on to this and not quite understanding what the process would be.

So, for instance, I have a database update query which has form data $_POST fields sent from the form to the API and then various steps, conditions, insert and update queries within the API.

What you are saying is, at the end of this API put a final Database Update Query which will update a database table, for example

Table

  • tbl_user_audit

Fields

  • audit_id (auto increment)
  • audit_login_user (auto fill from Security Provider)
  • audit_activity (??)
  • audit_date (CURRENT_TIMESTAMP)

What is it that you would insert into 'audit_activity' ?

audit_activity can hold the $_POST json as it is - this will indicate the data that was passed to the API Action for execution and hence can help in tracing those steps in case it may be required.

Alternatively, you can also setup custom values in a Set Value step within the API to accumulate useful data to save for future ref in the audit_activity field. This one is difficult to config and maintain though!

And, you might want another field api_action to hold the name of the API action that inserted that audit log - this name can be retired directly from server side function (in PHP am sure, Node & ASP, not so sure, but i guess there should be one)

Useful info :smile:

It's this part that I am looking for help. How do I get this into the database? Can you show me?

what server model are you using?

Current set-up : SPA Pages, Windows 10, MySQL, PHP

Wappler Version : 3.9.5
Operating System : Windows 10 Pro 64bit
Server Model: PHP
Database Type: MySQL/MariaDB
Hosting Type: custom

Server Software:
Apache: 2.4.46 Port 80
PHP Version: 7.3.21
MySQL Version: 8.0.21 - Port 3306 - DBMS
MariaDB Version: 10.4.13 - Port 3307
phpMyAdmin: 5.0.2

Hi @UKRiggers

I use https://clicky.com for our apps and the real-time view I have open all the time to watch where people go. It also has lots of options for setting up monitoring for specific targets etc… and not too pricey!

Interesting but too complex for this particular requirement. We’re looking for something like @Dave’s first post above. I will certainly keep note of this for other projects.

1 Like

Ah! To be able to save a json body via a query in an api action you’ll need to encode the json - we made a custom formatter to do this.
It cannot be done natively with Wappler.

In node there is a built in option (built into node, not wappler) that can be used in api actions.
But for php, must create a custom formatter to encode json.

Ah, NODE comes back to haunt me :laughing:

And I’m not confident in creating my own custom formatter etc for this. Thanks anyway :slight_smile: