google analytics not working
Closed this issue · 5 comments
DerRene97 commented
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
Hi, the file google-analytics.latte
is currently not used anywhere. You can put your tracking code in body.latte
DerRene97 commented
Tried that, but the whole site is unavailable as soon as i put the tracking code in the body.latte..
Wruczek commented
Can you paste your code here?
DerRene97 commented
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
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>