Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Analytics does not work #269

Closed
petzi53 opened this issue Sep 11, 2017 · 4 comments
Closed

Google Analytics does not work #269

petzi53 opened this issue Sep 11, 2017 · 4 comments

Comments

@petzi53
Copy link

petzi53 commented Sep 11, 2017

I believe that Google Analytics Templates are missing.

{{ template "_internal/google_analytics.html" . }}
{{ template "_internal/google_analytics_async.html" . }}

I added them to single.html and list.html. I got no error message, but Google still did not track.

Then I added the complete code Google provides and tracking worked fine!

<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

  ga('create', 'UA-106XXXXXX-1', 'auto');
  ga('send', 'pageview');

</script>

No idea what is wrong here. Maybe a faulty Hugo template or a problem with blogdown? This happened already with the Disqus template: A Hugo template did not work and had to be replaced by a different code snippet.

I will report this issue on StackOverflow as well (and if there is no answer than directly to Yihui Xie).

@gcushen
Copy link
Collaborator

gcushen commented Sep 11, 2017

I'm unable to reproduce this behaviour - GA appears to be working fine when I enter a valid GA ID into googleAnalytics parameter in config.toml.

@petzi53
Copy link
Author

petzi53 commented Sep 11, 2017

Thanks! Sorry for the inconvenience. I posted the problem already on S0.

(Did you receive my email about the blogdown tutorial with your theme?)

@petzi53 petzi53 closed this as completed Sep 11, 2017
@yihui
Copy link
Contributor

yihui commented Sep 13, 2017

I have figured out the fix, although I don't completely understand it: https://stackoverflow.com/a/46207854/559676

@gkrstulovic
Copy link

I have the same problem. GA doesn't see any activity after the last update. My site is gitlab. The fix by yihui didn't work for me.... Any idea how to solve it on gitlab?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants