1 minute read

If you are blogging using the popular jekyll theme Minimal Mistakes, this post will help you adding your google analytics tracking code on your site.

First open an account in Google Analytics and create a new stream using your website/blog URL. Google Analytics currently provides a g-tag for a site and you have to add the tag to your site. Therefore, you will find a tracking code like G-1234567890 associated with the stream.

First, make sure if you have the google-gtag.html file in your repository. The following script named google-gtag is already provided in the official repository analytics folder.

<!-- Global site tag (gtag.js) - Google Analytics -->

<script async src="https://www.googletagmanager.com/gtag/js?id=G-1X97YRKH1L"></script>


window.dataLayer = window.dataLayer || [];

function gtag(){dataLayer.push(arguments);}

gtag('js', new Date());

gtag('config', 'G-1X97YRKH1L', { 'anonymize_ip': false});


Now, add the tracking code to the _config.yml file under tracking_id option.

  provider: "google-gtag"
    tracking_id: "G-1234567890"
    anonymize_ip: false # default

Or you can add the code in a custom.html file and select provider: "custom" in the _config.yml file.

If you want to read how to add Google Adsense in minimal mistakes theme, feel free to read the following post:

Google Adsense in Jekyll Static Site or Minimal Mistakes Blog Theme


  1. https://github.com/mmistakes/minimal-mistakes/issues/85
  2. SEO Social Sharing and Analytics Settings

Leave a comment