ezhil icon indicating copy to clipboard operation
ezhil copied to clipboard

Google Analytics

Open jserpapinto opened this issue 4 years ago • 3 comments

Hey,

Great job with the theme. Thanks.

GA is not working properly for what it looks like to me. I've checked that currently they use a different tag than the one you are setting.

I haven't found how you do that magic to inject GA code, otherwise I would try to make a PR.

New code:

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

  gtag('config', 'UA-XXXX-XX);
</script>

Old code:

<script type="application/javascript">
var doNotTrack = false;
if (!doNotTrack) {
	window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
	ga('create', 'UA-XXXX-XX', 'auto');
	
	ga('send', 'pageview');
}
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>

I would suggest keeping the doNotTrack condition, but update to the more recent code.

Thanks

jserpapinto avatar Oct 28 '19 21:10 jserpapinto

Actually its an internal template built into Hugo - https://gohugo.io/templates/internal/ Either we have to create a issue in Hugo repo or ditch internal template and use our own.

vividvilla avatar Jan 05 '20 06:01 vividvilla

Having the same issue trying to set up Google Analytics right now with my site using ezhil - what would you recommend?

narner avatar Jan 12 '21 19:01 narner

Bumped into this problem too. There's an upstream Hugo issue here. The workaround was to use the analytics code recommended by Google and load it via an external JS script - example.

bill3tt avatar Jun 21 '22 15:06 bill3tt