Google analytics plug-in : analytics.js vs gtag.js

Context : OJS ; single-journal instance ; Google Analytics Plugin version

I am not familiar with Google Analytics and I have had this question from one of our journal editor regarding Google Analytics.

This person recently received a message from Google inviting him to take action in order to take advantage of the new Google Analytics (version 4 if I understand correctly (?)) for his journal in order to benefit from more advanced features with tracking. This journal is already using the plugin with their registered UA-XXXXX-1 number. The journal editor manages himself his Google Analytics account so I don’t necessarily know how it’s set up on their end (but I would assume they are probably not using Google Analytics with Google Tag Manager (?)).

The email message states that the actual analytics.js JavaScript library should be updated to the newest (and only maintained/updated from now on (?)) gstag.js.

The OJS Google Analytics Plugin (our installed version of the plugin nor the latest code seen for the OJS 3.3.x version(googleAnalytics/ at stable-3_3_0 · pkp/googleAnalytics · GitHub)) seems to refer to the analytics.js and doesn’t seem to be updated for the latest gtag.js, is that correct?

At this stage how can we have this journal register for the new tag? Should the plugin be modified/updated ? Or maybe he will have to have Google Tag Manager installed on his end first… or not (not sure how this works)?

Thanks for your help,

Marie-Hélène V.

I’m sorry; I just came across this post ( right after I submitted mine (I don’t understand why my preliminary search didn’t find it).

Am I to understand that once a GT code is obtained (this would be the first step then), I can simply modify the lines (Google Analytics 4 in OJS3.3.x - #5 by yasielpv)? Do the UA code and the GT code are meant to live together or once updated/remplaced, only the GT code remain?

Many thanks,

Marie-Hélène V.

Hi, @Marie-Helene By replacing the code shown here, Google Analytics 4 in OJS3.3.x - #5 by yasielpv, the Google Analytics plugin will start working with Google Analytics 4 (GT) instead of working with Google Analytics Universal (UA). Only the GT code will be remain.
A solution to keep the data obtained with UA in the GT property is to link both properties from Google Analytics, and thus the previous data obtained by UA would not be lost, and the new ones would be obtained by GT

Thank you Yasiel. Very helpful.