Google Analytics in Minimal Mistakes Blog Theme
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>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-1X97YRKH1L', { 'anonymize_ip': false});
</script>
Now, add the tracking code to the _config.yml
file under tracking_id
option.
analytics:
provider: "google-gtag"
google:
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
Related Posts on Jekyll/ Minimal Mistakes
- Google Adsense in Jekyll Static Site or Minimal Mistakes Blog Theme
- How to Enable Facebook Comments Plugin in Jekyll Blog Posts
- Minimal Mistakes Cheat Sheet: Code Snippets I use to Blog using Jekyll and the Minimal Mistakes Theme
- Jekyll SEO: How to Find and Fix 404 Error on a Jekyll (Minimal Mistakes) Blog Website
- Medium: How to Effectively Perform Search Engine Optimization to a Jekyll (Minimal Mistakes) Blog Post Header
- How to Add Latex Math to Jekyll-based Theme- Minimal Mistakes
- Tools and Platforms I use for Blogging
- How to install Jekyll with the Minimal Mistakes Theme in macOS
Leave a comment