Updated to GA4, see #25253

This commit is contained in:
Francesco Mangiacrapa 2023-06-12 15:36:10 +02:00
parent b30f5c10c1
commit 272f2c6add
2 changed files with 14 additions and 1 deletions

View File

@ -150,6 +150,10 @@ class GoogleAnalyticsPlugin(GAMixinPlugin, p.SingletonPlugin):
"googleanalytics_fields": str(self.googleanalytics_fields),
"googleanalytics_linked_domains": self.googleanalytics_linked_domains,
}
#return p.toolkit.render_snippet(
# "googleanalytics/snippets/googleanalytics_header.html", data
#)
# Updated to GA4 #25196
return p.toolkit.render_snippet(
"googleanalytics/snippets/googleanalytics_header.html", data
"googleanalytics/snippets/gtag_header.html", data
)

View File

@ -0,0 +1,9 @@
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{googleanalytics_id}}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{googleanalytics_id}}');
</script>