Hugo-theme-zzo: How to add Google Analytics? It doesn't seem to work

Created on 1 Dec 2019  路  11Comments  路  Source: zzossig/hugo-theme-zzo

google_analytics  = "<my-id>"

It doesn't seem to work.

Google tag assistant prompt:

result of Tag Analysis : 2 In total 2 Errors.

Where to optimize : No HTTP response detected

Most helpful comment

just put this code in /layouts/partials/head/meta.html,its work.

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

  gtag('config', '<my-id>');
</script>

All 11 comments

Hmm, I haven't tested it yet. I'll do this just a moment

@fandean It seems like google analytics not working now. I'm not familiar with this part. I have to investigate more. Do you want to use Google analytics and google tag manager both or just google analytics? I need some time for doing this

I just need Google Analysis. It's not urgent

Ah Ok~ Until then, we can keep this issue open.

just put this code in /layouts/partials/head/meta.html,its work.

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

  gtag('config', '<my-id>');
</script>

鍏刣ie锛屼綘濂藉憖

Thanks for the information! I'll try it馃槃

I just moved the googleAnalytics param from params.toml to config.toml file. And I just followed the Hugo docs guidelines. So, just set the googleAnalytics param to your ID. I've not tested it yet because It needs to host a website. I hope it works.

Hi, it's working

Sounds great!

did you add the code in the format:
googleAnalytics: "G-01234xxxxx"
in config.yaml ?

It does not work like that on my side.

Was this page helpful?
0 / 5 - 0 ratings