We are looking at options to revamp analytics tracking across a number of Meteor apps, most of which use Blaze but some in React.
When I started digging into current best practices, I’m finding… not much current for the state of Meteor 2023.
Is anyone aware of a comprehensive guide that covers various analytics platforms for various frontend frameworks?
OK GROW!'s analytics package (both of them) was great for a long time, but is has been unmaintained for four years now. Is there a new universal package that offers similar functionality?
Suggest taking a look at PostHog. I haven’t played around with it extensively but it sounds promising. You may be able to use just it instead of relying on several different analytics providers.
To compare different analytics providers, I ended up writing my own analytics wrapper but my hope is to rely on as few providers as possible.
It integrates Google Analytics and usually I use the server side option so the tag is already injected in the boilerplate but you can also use it in the client.
The server option is great when you don’t care at all about what technologies you are using in the client.
These lines do all the work:
import { onPageLoad } from 'meteor/server-render';
import { addGoogleAnalyticsScript } from 'meteor/quave:analytics';
onPageLoad(sink => {
addGoogleAnalyticsScript(sink);
});
If you run your own analytics platform, you are in control of everything, there is no 3rd party in between. If you play fair, you can be GDPR compliant while getting some user data.
With google … you never know.
I stopped using them and moved on to ownership.
I went for this: https://matomo.org/ and I thing I will never go back to google for analytics.
I agree that it is wise to move to more privacy compliant solutions. We did the same. Though @filipenevola’s package is nicely put together and can be adapted to use Matomo’s scripts instead. We built a similar one internally, not knowing this exists
We ended up setting up our own analytics framework.
For route changes, we hook into any changes in the “history”. We use the history package for this, create a browser history (which is also used for Redux) and then listen to changes. On every change, we trigger events in Google Analytics and Facebook, but this could be easily extended to other services like Matomo.
Plus, we offer all components access to tracking functions that can be called from anywhere to track custom events.
This gives us all the flexibility we need, without fiddling around with any 3rd party packages.
In general, the more experienced I got with Meteor, the more I tried to avoid 3rd party packages wherever possible. If they get abandonded (which was quite common in the Meteor ecosystem over the past years), you get stuck in limbo or you have to fork them anyways.
I stopped looking at Google Analytics, just not worth the time. I can do much more by spending my time on fixing bugs, developing new features and handle CS request in a timely manner.