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=""></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'UA-xxxxxxxxx-1');
$ pandoc --standalone --include-in-header=header.txt in.markdown -o out.html

Tried with: Pandoc and Ubuntu 18.04

© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘📧