Integrate google analytics with papermod theme, how?

Adding Google Analytics and AdSense to a Hugo website.

I was reading this blog post. But turns out the papermod theme is vastly different than minimal theme and it has its own configurations. Can anyone tell me where do I need to paste my google analytics script that looks like this.

<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src=""></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments)};
  gtag('js', new Date());

  gtag('config', 'UA-100000000-1');

I’ve integrated google analytics with papermod theme by doing this:

In hugo_root/hugo.yaml

googleAnalytics: G-XXXXXXXXXX

In hugo_root/layout/partials/google_analytics.html, I put the script.

Then in ./themes/papermod/layouts/partials/head.htmlI’d put this

{{ partial "google_analytics.html" . }}

Next is to put google adsense :smiley:

Look at the sample config.yml configuration of Papermod: replace googleAnalytics: UA-123-45 quite in the beginning with your own code.

That should be all you have to do.

Already did as mentioned above. Is it possible to integrate adsense?

I just followed same procedure and integrated adsense as well.

That was deprecated. Config | Hugo

This is a parameter in the pagemod theme, not the deprecated GoHugo parameter.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.