Hacker News new | ask | show | jobs
by runninganyways 2337 days ago
Or you could write the 10 lines of JavaScript that'll do what 99% of people use Google analytics for
3 comments

If you think you can replicate that with 10 lines you have no idea what Google Analytics is used for.
I'm ashamed to admit that I use GA on my blog to essentially count page views. The other information is interesting but mostly unused (by me). I would be far better served by a tool or service handling server logs (any recommendations?). But GA is 0 friction, so it's what I picked up back in the day. I suspect there are a lot of people in this boat.
Even for page views, 10 lines of code won't replicate GA. Try counting how many hits, and you will find that all the bots and spiders quickly make the numbers meaningless.

Of course, if that is all you are doing, you should be using Matamo or Fathom or whatever, but it is not fair to say GA could easily be replaced.

Many of the common web log analyzers are a bit long in the tooth.

I've have used GoAccess for a while now and is mostly happy with it. It's fast enough and can generate pretty good looking static html which is mostly what you want for those simple use cases.

A side effect of processing log files is that you can freely try software on historical data.

Do you have a recommendation on log format for GoAccess? I run a lot of custom services with no nginx etc in front, so I'll have to figure out the logging myself.
You can always create an issue on their github page, lots of help in there: https://github.com/allinurl/goaccess/issues
Matomo can also be used to analyze server logs.
19USD/mo for 3 sites seems pretty steep, and I have 0 interest in managing my own PHP service. Is there anything cheaper in this space?
Just a shot in the dark, but if you use Cloudflare already, their stats include view counts. It's also probably more accurate than relying on JS tracking tools because they can count the actual requests to your site.
My CloudFlare stats show multiple times as many hits as GA. I'm guessing it's not handling bots/spiders or something.
Those 10 lines probably depend on an npm package that relies on 100 other npm packages.
Feel free to post those lines
I reckon you'd need more than 9 "\n" characters to get it done.

But in seriousness the 10 lines would be just use local storage or wotnot to store a tag, then call tracker.com?tag=... on each page load. "Rest is done on the server (TM)"

This really reminds me of the infamous "you can just use FTP instead of Dropbox" comment.
I don't disagree, but in a bit of fairness, a lot of people just use GA for page-counts and basic correlation stuff...you could do that in a relatively small amount of frontend JS stuff and a slightly-more-complex backend API to handle the basic correlation stuff.

That said, that will only do about .01% of all the features of GA; like the infamous "FTP vs. Dropbox" the premise itself isn't exactly "wrong", just missing a bigger point.

Could you link me to the FTP vs. Dropbox discussion? I am curious. I haven't used either for years and the implication seems to be that there is a profound difference, so I wonder what it is.
This is the 'infamous' original thread in question: https://news.ycombinator.com/item?id=8863
That is cute, thank you.