Google Analytics 4 in OJS3.3.x

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

4 Likes