3 ms·
Writing it myself is what I did for my blog. The only thing I capture is the page that was visited, when it was visited, and the domain of the referrer (to see
by akdas 5y ago
Writing it myself is what I did for my blog. The only thing I capture is the page that was visited, when it was visited, and the domain of the referrer (to see what the source is). The tracker is meant to be used for blogs where I don't control the server, such as Github Pages, so there's a single AJAX call to my self-hosted server.
I usually open source my code, I just haven't gotten around to it for this one in particular. Might be worth doing if people are interested.
- arthurcolle 5y agoYeah sure! Please do open source it if you choose to, I've been thinking about something similar but it's just not pressing vs. all the other stuff I'm working on. I literally haven't given it much thought beyond "ok intercept the request from a visitor, do some analytics on the IP address, and then log visits of logged in users/new visitors" > The only thing I capture is the page that was visited, when it was visited, and the domain of the referrer (to see what the source is). The tracker is meant to be used for blogs where I don't control the server, such as Github Pages, so there's a single AJAX call to my self-hosted server. To be honest, I'm not entirely sure how I'd solve this without the 'single AJAX call' but I guess it makes sense to start there! Curious how you implemented it - again, I'm not a rocket surgeon and this is just like a 3 second analysis of the problem space, but it's always neat to check out other people's implementations for common, shared problems
- akdas 5y agoFor sure! Because this was for my own use, I need to put in some documentation for it to be useful for others. That, and pick a name :) It's all on my TODO list. You're right: if you don't control the server, you basically can't intercept any requests without this extra AJAX call, or some similar mechanism like a tracking image served from your own server. Essentially, you need to make a request to your own server at some point! The architecture is pretty simple: 1. Insert the AJAX request into each page, sending the page URL and the referrer in the payload. Because I found some weirdness with tools like Pocket serving my pages from some cached location, I use my static site generator (Jekyll) to embed the page URL into each page, instead of pulling it from the client side. 2. I support multi-tenancy on a single tracking server by using multiple domain names. Based on the incoming domain name, I have nginx attach an additional header to the request that says which site is being tracked. This way, I can have my personal blog and my newsletter website both tracked by the same tracking server instance. 3. Then, it's just a matter of storing the data (page URL, time of visit, referrer domain, which site) into a SQLite database. 4. And of course, I have a small web UI to view the data. Note that I don't do anything with the IP address of the visitor. That's personal data that I don't track.