Wruczek / ts-website

A website for your TeamSpeak 3 server
https://ts.wruczek.tech
GNU General Public License v3.0
344 stars 80 forks source link

google analytics not working #209

Closed DerRene97 closed 2 years ago

DerRene97 commented 2 years ago

Hey, i've tried to put my google analytics in the google-analytics.latte file. But somehow the code is not working as expected, google analytics is not showing anything.

How to fix that?

Wruczek commented 2 years ago

Hi, the file google-analytics.latte is currently not used anywhere. You can put your tracking code in body.latte

DerRene97 commented 2 years ago

Tried that, but the whole site is unavailable as soon as i put the tracking code in the body.latte..

Wruczek commented 2 years ago

Can you paste your code here?

DerRene97 commented 2 years ago

Sure, just removed my personal code tho

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=PERSONALCODE"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'PERSONALCODE');
</script>
Wruczek commented 2 years ago

Characters { and } have special meaning in latte and must be escaped. Replace all { with {l}, and all } with {r}:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=PERSONALCODE"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){l}dataLayer.push(arguments);{r}
  gtag('js', new Date());

  gtag('config', 'PERSONALCODE');
</script>