3 ms·
Good suggestion, angersock — though it might take a bit more than an afternoon to get it done ;)
by rywalker 11y ago
Good suggestion, angersock — though it might take a bit more than an afternoon to get it done ;)
- angersock 11y agoIt's not too bad, honest! Use an events model for analytics--track page loaded, page left, and maybe a handful of other events (to taste). Spec out that the API (from the client JS) is something like: emitAnalyticsEvent( eventType, location, browserTime, optionalData ) Register some event handlers to call this. browserTime and location (from navigator) are done to allow handling of single-page routing properly. On the server side, on receipt of the request, timestamp it again, and insert wholesale into a database table (in postgres, use the jsonb type to store the unstructured optionalData ). In optionalData, note the userAgent and IP from the headers. Additionally, note the session and user associated with the event. Congratulations! You've now got a flexible (albeit barebones) setup. Visualizing and analyzing the results may take more than an afternoon, but that's outside the collection scope. Even still, it's trivial to show user history, visitor IPs, and high-level traffic patterns.