I should say this is purely a statistical thing that needs to be 99% accurate and directionally correct. In other words, there's a little room for error.
I'm currently doing this with a piece of middleware that checks req.headers.referer and updates Mongo if the user hasn't come from one of my pages. That's resulted in me making an addition to almost every instance of app.get. It works, but I don't know if it's the right solution.
Here are my concerns -
It's starting to look messy. I feel like I'm on a slippery slope to middleware hell, which almost every piece of middleware I add being needed for almost every route. Lots of repeated calls. Lots of samey looking code.
Is it efficient? I know it'll only get called once per request, so my concern really is related to the above. I'm I beginning something that will result in a long chain of middleware before the user gets a response?
(I'm new to Node, Express, and Mongo, so if you're wondering why I haven't done something obvious, that's probably the reason)