Learning Google Analytics - How I set up google analytics for this blog

Cite & Disclaimer

Please note that I have obtained all my information from:

I am merely writing down notes for myself here to replicate how to do this again and anything thing I’m finding lacking.

Introduction

I’m mostly setting this up as an exercise in curiosity to see which of my pages are being viewed, how to set up google analytics and how the reporting works.

Google Analytics

When I started this I previously had an older account of Google Analytics (Universal Analytics). I upgraded the account to use the Google Analytics 4 data models.

According to this site, https://www.optimizesmart.com/google-analytics-4-ga4-vs-universal-analytics-what-is-the-difference/, there seems to be a lot of differences around setup, models, and administration of the analytics.

Setting up Google Analytics for your Jekyll Site

Firstly after logging into your google analytics you will need to add a new property to your account.

  1. Click the to navigate to the admin page.
  2. Create a new property for the selected account you want.
  3. Go through the setup for the property.
  4. Add a new web datastream by copying the “Global Site Tag (gtag.js)” code with the following formatting to a new file labelled analytics.html in your _includes folder.
     <script async src="https://www.googletagmanager.com/gtag/js?id={{ site.google_analytics }}"></script>   
     <script>   
       window.dataLayer = window.dataLayer || [];   
       function gtag(){dataLayer.push(arguments);}   
       gtag('js', new Date());   
          
       gtag('config', '{{ site.google_analytics }');   
     </script>   
    
  5. Add the “Measurement ID” into your _config.yml
     # Google Analytics
     google_analytics: UA—XXXXXXXX-X
    
  6. Add the following as the FIRST line after the <head> tag in the head.html
     {% if site.google_analytics and jekyll.environment == 'production' %}   
     {% include analytics.html %}   
     {% endif %}   
    

Issues

Can’t seem to figure out how to view the report for page views.
It looks like it’s in the Life Cycle -> Engagement -> Pages and screens section but nothing is coming up.
Will have to check on this later.