Determine duration of visit to each view

Hi all,

as part of my evolution of this Aurelia app -Tutors, am looking to measure the time users spend on each view. Although I have Google Analytics PageView/Events working fine, am looking for a more bespoke approach.

Essentially, I am seeking an elegant technique to measure - to the nearest minute - how long a specific page/view is on screen for a user. From this I propose to generate a heat map

The above is based just on discreet ‘visit count’ - but time based metric far more useful. Should I be looking to wards the Aurelia Animations machinery? Or perhaps subscribing to Router events?

Thanks in advance - any help appreciated!

Reader app : https://github.com/edeleastar/tutors-design
Analytics app : https://github.com/edeleastar/tutors-scope

Regards
Eamonn

2 Likes

Or perhaps subscribing to Router events?

Does that mean a service will start/stop recording when a route is activated/detactivated? If so, it seems you already have some idea in mind. I think it’s pretty granular already, unless you want to go further. If so, can you share some ideas what else related to session timing you want to know more about?

Thanks for the swift response!

Yes, if I could be informed of every route change - the I can probably build a time calculation around this event, and work it into the data logging easily enough.

However, how to intercept/listen in for a route change? (Reasonably generically). I.e do I have to modify all views - activate/deactivate - or can I set up a single event listener?

Thanks!
Eamonn

1 Like

I see. I think you can use the events as seen in the enum here https://github.com/aurelia/router/blob/master/src/router-event.ts . If you use an older version of the router, you can usenthe value directly, or copy paste that enum and listen to those event on the event aggregator.

Very useful place to start - thanks!

1 Like