How to create your simple version of google analytics real-time using Nun-db
One of the features I like the most about Google Analytics is the real-time user track. Randomly during my day, I visit the real-time analytics of all products I run to see how many people my work is impacting at that time. It gives me the energy to see my work affecting other people. On the other hand, there are some drawn backs of using google analytics, to name a few:
- Technical user may block google analytics to avoid been tracked (and you will not see that traffic in your tool)
- You are giving data to google for free just to use a simple feature that may not be worth paying for at all. Or maybe you won’t even use most of it’s features.
To skip all that drawn backs, how can you create an online users count using Nun-db?
Crete a database for your site
How to count connected browsers?
Nun-db has a native function to count the number of open connections to a database, so here you don’t need to write any piece of code to push the number of users on your site, all you need to do is to connect to Nun-db, and that is it.
Here is how you do it,
Add the element to receive the users count that you just created
You can see it in action in this very blog (Going to the about link at the end of the page). Check out the next gif showing it working!
- Little code (simplicity).
- 0 User data (privacy) you will need 0 data from the user reading your site, and this is respectful.
- You can self-host it and avoid the tracker been blocked by the tracking blocker (all data is yours).
Problems with this implementation
- If the user opens multiple browser windows, it will count as various users online.
- The user may leave the browser open, and it will still count as online.
- Real-time Medical Image Collaboration POC Made Easy with OHIF and Nun-db
- How to create users with different permission levels in Nun-db
- Match vs Hashmap! Which one is faster in rust?
- Towards a More Secure Nun-db: Our Latest Security Enhancements
- Building a Trello-like React/Redux App with Nun-DB with offline and conflict resolution features
- Introduction to managing conflicts in Nun-DB
- Keepin up with Nun-db 2023
- The new storage engine of Nun-db
- Stop procrastinating and just fix your flaky tests, it may be catching nasty bugs
- An approach to hunt and fix non-reproducible bugs - Case study - Fixing a race conditions in Nun-db replication algorithm in rust
- Nun-db the debug command
- Keeping up with Nun-db 2021
- Writing a prometheus exporter in rust from idea to grafana chart
- Integration tests in rust a multi-process test example
- Leader election in rust the journey towards implementing nun-db leader election
- How to make redux TodoMVC example a real-time multiuser app with nun-db in 10 steps
- A fast-to-sync/search and space-optimized replication algorithm written in rust, The Nun-db data replication model
- NunDb How to backup one or all databases
- How to create your simple version of google analytics real-time using Nun-db
- Migrating a chat bot feature from Firebase to Nun-db
- Keepin' up with Nun-DB
- Going live with Nun-DB