Google Analytics - Updated GA4 Tag and Script
authorTerran McCanna <tmccanna@georgialibraries.org>
Tue, 16 May 2023 14:19:18 +0000 (10:19 -0400)
committerChris Sharp <csharp@georgialibraries.org>
Wed, 24 May 2023 12:11:43 +0000 (08:11 -0400)
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Open-ILS/src/templates-bootstrap/opac/parts/config.tt2
Open-ILS/src/templates-bootstrap/opac/parts/goog_analytics.tt2

index 58cf366..d0abba1 100755 (executable)
@@ -49,7 +49,7 @@ openurl.baseurl = 'http://sfx.example.com/instance';
 # valid Google Analytics code and changing 'false' to 'true'
 ##############################################################################
 google_analytics.enabled = 'true';
-google_analytics.code = 'UA-66988802-1';
+google_analytics.code = 'G-GVGQ37XH17';
 
 ##############################################################################
 # Ebook API integration
index c5927db..36bcbe3 100755 (executable)
@@ -1,18 +1,13 @@
 [%- PROCESS "opac/parts/header.tt2";
     IF google_analytics.enabled == 'true' %]
 
-<!-- http://www.google.com/support/googleanalytics/bin/answer.py?answer=174090 -->
-<script type="text/javascript">
-    var _gaq = _gaq || [];
-    _gaq.push(['_setAccount', '[% google_analytics.code %]']);
-    _gaq.push(['_trackPageview']);
+<!-- Google tag (gtag.gs) -->
+<script async src="https://www.googletagmanager.com/gtag/js?id=[% google_analytics.code %]"></script>
+<script>
+  window.dataLayer = window.dataLayer || [];
+  function gtag(){dataLayer.push(arguments);}
+  gtag('js', new Date());
 
-    (function() {
-        var ga = document.createElement('script');
-        ga.type = 'text/javascript'; ga.async = true;
-        ga.src = ('oils:' == document.location.protocol || 'https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-        var s = document.getElementsByTagName('script')[0];
-        s.parentNode.insertBefore(ga, s);
-    })();
+  gtag('config', '[% google_analytics.code %]');
 </script>
 [%- END %]