Calculating analytics for webpages

I am a Computer Science undergrad from The National Institute of Engineering, Mysore. I freelance while working at Twilio as Software Developer Engineer (l1).
Search for a command to run...

I am a Computer Science undergrad from The National Institute of Engineering, Mysore. I freelance while working at Twilio as Software Developer Engineer (l1).
No comments yet. Be the first to comment.
A log of building a saas product to serve as a complete work desk for an influencer and there team, inclusive of calendar, mail, content management, portfolio website and some spicy AI tools.
Building Reach
In the era of short-form content dominance, creating engaging YouTube Shorts consistently can be a time-consuming challenge. Today, I'm excited to share a comprehensive technical breakdown of an open-source YouTube Shorts generator that automates the...

In a world where communication is key, email templates play a crucial role in delivering messages effectively. Explore the transformative power of React in simplifying the intricate art of crafting email templates. From streamlined development workfl...

Tech stack breakdown: Reach | Building my SAAS

A small story of me learning micro services, gRPC and a multitude of things.

Lately, I've been diving deep into the world of my SaaS product, Reach. I've been thoroughly immersed in figuring out how to calculate basic site analytics—focusing on the usual suspects like views, unique views, clicks, and a range of other interesting metrics. It's been a bit of a rollercoaster, so I thought I'd give you a quick recap of the journey I've been on while striving to achieve these analytics goals with Reach. Buckle up for the ride! 🚀
To give you some context, the web pages we're discussing are straightforward contact pages, similar to a basic Linktree page—essentially a webpage that lists all your important links and products. When dealing with such pages, the metrics that users are most interested in are clicks, unique clicks, and similar engagement indicators.
Here's a breakdown of the key metrics we'll be tracking:
Views
Clicks
Unique Views
Unique Clicks
Geographical distribution of views and clicks
Being a tech enthusiast, I find the setup far more exciting than the actual calculation of metrics. Ideally, the analytics system should be built on top of a messaging queue, allowing it to handle a multitude of click and view requests without overwhelming the server.
In our case, since we're just starting out and not expecting a flood of users or views, we opted for a simpler setup with a Flask server handling incoming requests. These requests are then added to a MongoDB collection. We chose MongoDB because of its excellent aggregation capabilities, which are crucial for the analytics we’re building.
As you're probably aware, calculating basic metrics like views and clicks is relatively straightforward. When a page loads, we send an API request to log the view. Similarly, when a link is clicked, another API request logs the click.
The interesting part comes with calculating unique clicks and views. There are multiple ways to approach this, but for now, we've decided to use IP addresses and user agents. This method not only helps in distinguishing unique users but also allows us to use the IP data to calculate geographical distribution. This is how we've set up our web page analytics so far.