Google Analytics 4 in OJS3.3.x

Hello friends, Google analytics is currently using GA4 for page access measurement, and is leaving aside Universal Analytics (UA). Does the current GA plugin support this new GA4 version?
Greetings!

3 Likes

HI @dagosalas, our Publishing Services team recently identified this as a priority. I believe they’ll be putting out a new version of the plugin at some point.

1 Like

Any updates on this fix?

Hi @PaulS, I checked with out Publishing Services team and they have not done any work on the Google Analytics plugin. Can you point us to any information about when Google plans to remove support for UA?

1 Like

Hi @NateWr, the change in the plugin of Google Analytic for supporting GA4 is to modify the lines googleAnalytics/GoogleAnalyticsPlugin.inc.php at 8990b7768ebd02adc2c1fa4ba8c01c8b760d47dd · pkp/googleAnalytics · GitHub
for

			$googleAnalyticsCode = "
(function(i,s,o,g,r,q,a,m){i[q]=i[q]||[];i[r]=i[r]||function(){i[q].push(arguments)}; a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.googletagmanager.com/gtag/js?id=$googleAnalyticsSiteId','gtag','dataLayer');
  gtag('js', new Date());
  gtag('config', '$googleAnalyticsSiteId');
";

I tested it, and It works, also I improved the plugin by adding a way of selecting the GA version like the picture, but the code above is the solution for the GA4 feature.
image

3 Likes

Thanks @yasielpv!

@mfelczak, were you interested in this or happy to stick with GA Universal for now?

1 Like