Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to add Google Analytics to Pandoc webpages

📅 2019-Jul-06 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ google analytics, pandoc ⬩ 📚 Archive

Pandoc can be used to convert Markdown files to HTML webpages. If you are hosting these webpages online, it might be useful to get some stats on them. Google Analytics is a popular service to do this.

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxxx-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'UA-xxxxxxxxx-1');
</script>
$ pandoc --standalone --include-in-header=header.txt in.markdown -o out.html

Tried with: Pandoc 1.19.2.4 and Ubuntu 18.04


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧