NIAEFEUP / nijobs-fe

[FRONTEND] A platform for companies to advertise their job opportunities to students
GNU General Public License v3.0
23 stars 3 forks source link

Change analytics to use GA4 features #319

Open BrunoRosendo opened 1 year ago

BrunoRosendo commented 1 year ago

In #318 we successfully ported NIJobs from GA3 to GA4. This ensured that our analytics correctly worked with the new system, since GA3 was deprecated on the 1st of July 2023.

GA4 has a completely new interface and data flow but Google made the transition easier by automatically translating old mechanisms to the new ones. GA4 is imo simpler than GA3, everything is based on events and event parameters.

This means we can still use the old API (e.g. dimensions and old event system) and they'll all be converted into events and event parameters. However, this also means our code isn't very clear when compared to the new dashboard.

Additionally, we could be making better use of the new flexible events. Previously, our events were limited to a few parameters like action, category, and label, and the rest was handled by custom dimensions which imo were never that great, we were using them because of the platform's limitations. This completely changes in GA4, everything is controlled by event parameters and we have full control over them!

If you check the events in our dashboard, you'll see parameters like event_label which is simply a translation from the old system. We should rethink how we organize our analytics and truly do it however we want.

A good example of how this can be improved is the search analytics. We currently have a simple success event when a search happens (with the path as the label) and the rest was set separately in dimensions. We can now use the same event and pass as many parameters as we want, with all the search fields! The same goes for other events and dimensions we currently have. Take a look at src/utils/analytics/constants.js for an overall view of all dimensions and actions.

Finally, I'll leave you with a few links that helped me understand this transition: https://support.google.com/analytics/answer/9973999?hl=en&utm_id=ad https://www.youtube.com/watch?v=Y6WxUEk6clw