Google Analytics 4: what to do with my custom theme?

by @cyballruiz

First, What is Google Analytics 4?

Google Analytics 4 (GA4) is the latest version of Analytics. With it, owners of websites and apps can get a more complete understanding of their customer's lifecycle. GA4 uses machine learning to uncover insights from your data by using modeling.


At Blogger we're using Universal Analytics (UA) which is a session-based model, groups the interactions within a given time frame together.


GA4 uses an event-based model where each user interaction is considered a standalone event.


If you want more information about GA4 and the differences between it and UA, I recommend you this article: [UA → GA4] Universal Analytics versus Google Analytics 4 data



How Analytics code is added to the theme?

Most of my custom-built themes contains the following line of code:

 <b:include data='blog' name='google-analytics'/>

This line of code will create the needed Analytic script ONLY IF the UA property ID is added to Settings > Basic > Google Analytics Property ID



At this moment, Blogger interface only works with UA property ID, so installing your new GA4 code needs HTML work at your theme.



How to add my GA4 property

  • Please save a theme backup
  • Open the theme's HTML editor
  • Find </head> and paste the GA4 code immediately before it

Most sites recommend adding it below <head> but I think it is not the best practice, scripts are heavy and will slow down your loading time.



Should you delete your UA Property ID?

Everyone asks “should I delete my Universal Analytics code?” The answer is NO.

Do not remove from Settings (or your theme if you added it directly) the UA property ID, especially if you're using an ad network such as Mediavine.



Related articles: