How to Fix Google Analytics in GeneratePress [After Changing Themes ]

You’d want to learn how to fix Google Analytics In GeneratePress after Changing WordPress themes.

If you are like me, chances are that you are a regular WordPress user. If and when things break with Google Analytics, here’s a handy guide to quickly help you set your Google Analytics right.

Recently, I changed WordPress themes from Divi to GeneratePress — I was just bored with the look of the previous theme.

Please note that Divi itself is a good theme to work with along with its family of tools such as Bloom, the Divi Plugin, and more).

I also wrote about how to hide categories and tags in GeneratePress & fix the general blog page default display. 

When I made that change last weekend, I realized that my Google Analytics code wasn’t tracking — the code just vanished straight out of the window (along with the theme). 

Note: Google Analytics is moving from Google Universal Analytics to GA 4. Everything in this post relates to basic Google Analytics 4 settings for WordPress. 

There are three ways you’d normally connect google Analytics with WordPress: 

  • Using a third-party plugin, like MonsterInsights 
  • Manually adding the Google Analytics tracking codes to your WordPress website 
  • By using Google Tag Manager. 

If you are using a third-party plugin like MonsterInsights, you’d just have to ensure that the plugin is still there (be sure to update the plugin). MonsterInsights is already geared up for GA and is presently “dual tracking” — tracking both Google Universal Analytics and GA 4.

The folks at MonsterInsights will move completely to GA4 when the time is right. 

I am sure that most popular Google Analytics plugins will do something similar. 

As for adding the Google Analytics tracking code to your website manually, you’d have to ensure that you add the new Google Analytics 4 (GA4) specific tracking codes on your website. 

If you are using Google Tag Manager, you’d need to add the Google Tag Manager codes to your website (and not the Google Analytics codes — since these are managed on the Google Tag Manager). 

Note: I assume that you have a basic understanding of Google Tag Manager and How to use it.

Watch this video that explains how to use the Google Tag Manager to manage tracking codes and scripts

Here’s how it’s done, using GTM (Google Tag Manager):

Total Time: 10 minutes

Step 1: Collect the Google Tag Manager Codes

Go to Google Tag Manager and login (your email login should be the one that you have permissions to use for the brand/container/analytics — a good practice is to have one single email for all of these Google Properties). 

Go to your container and click on it. 

On the top right-hand side, you’ll see something like GTM-XXXXXX, click on it. You’ll find a modal that pops up giving you two pieces of code (pertaining to Google Tag Manager).

GTM Codes Generatepress

Step 2: Add Google Tag Manager Codes To GeneratePress

For most WordPress themes — and especially for GeneratePress — it’s the header.php file you’d need to edit. 

In the WordPress admin panel, hover on “appearance” > Edit theme files > find “header.php” file. 

Locate the HTML tag <head>. 

Add one piece of code right below the <head> section of your WordPress site. 

Add code to head section WordPress Generatepress

Add Code to Body Section

Go back to Google Tag manager, collect the second piece of code, and add the second piece of code (above) right after where the <body> section starts.

Add GTM to generatepress body

Step 3: Test If the Code is Firing

You can use the Google Tag assistant to see if your Google Analytics codes are firing properly.

Or, visit your website, log into your Google Analytics dashboard, and check “real time” reports to see if Google Analytics is tracking visits to your website. 

When you add the Google Tag Manager codes to GeneratePress theme, all other Javascript codes, tracking codes, and other scripts you manage on Google Tag Manager (including the Facebook Pixel, The Quora Ads Pixel, the Adroll Pixel, etc.) will also fire.

GA4 Real time Snapshot

If you have any questions, please reach out to me by joining my LinkedIn Brand Page. Or follow me on LinkedIn or Twitter

See my YouTube videos for more tutorials. Or head to the fetchprofits academy and stock up on some free eBooks, courses, and more.

Some of the links in posts and elsewhere are partner links and affiliate links (the only way I keep some money flowing in). You can purchase some of these products and I make commissions which keeps the lights on. You never pay more. Sometimes, you get discounts. Thank you for understanding. Here's the Aff Discloure Policy (if you love that kind of stuff).