Google Analytics?

Hello. Has anyone figured out how to inject a google analytics tag into the html <head>? Is this even possible with Solara? Are there any other website analytics for Solara?
2 Replies
iisakkirotko
iisakkirotko3mo ago
Hi! This is in principle possible with custom jinja2 templates (and we do it for the solara.dev website, see https://github.com/widgetti/solara/blob/master/solara/website/templates/index.html.j2#L16-L22 ). We have also previously discussed both implementing other analytics providers, and making a proper API for GA, so this is on our radar. Just haven't gotten around to it yet, and it isn't in our immediate future plans :)
Monty Python
Monty Python3mo ago
solara/website/templates/index.html.j2 lines 16 to 22
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-KC98NKNL');</script>
<!-- End Google Tag Manager -->
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-KC98NKNL');</script>
<!-- End Google Tag Manager -->