The easiest way to add Google Analytics 4.0 to Divi

With the new version of Google Analytics (4.0), you might be wondering how to put the tracking code on your WordPress website using the Divi theme. As with most things in WordPress, there are many ways BUT in this blog post, I will show you the easiest way.

You won't need to use a plugin or make a child theme. Divi has an option to add the Analytics code easily.

I also want to note that you can't just carry over your old data and merge it with the new Google Analytics. You have to make a new property to use Google Analytics 4.

You can continue tracking using the old Google Analytics (Universal Analytics) and the new one, but my recommendation is just to make the switch. Remove the old one and just start tracking using Google Analytics 4.0. You can always check your historical data on the old Analytics.

Follow these steps to add the new Google Analytics code to your Divi site

  1. If you are switching from old Google Analytics, then go to the "Admin" section and click "Upgrade to GA4". If this is the first time you are making Google Analytics, then it will use the new analytics by default.

    Screenshot of how to upgrade to Google Analytics 4.0

  2. Click "I need to create a new Google Analytics 4 property" and "Create Property".

  3. Click "Tag Installation", then click on your website.

    Screenshot of tag installation for Google Analytics 4.0

  4. On the "Add new on-page tag" tab, click on "Global site tag" and copy the code.

    3b. If you want to keep tracking using both the old analytics property and the new one, click "use existing on-page tag", and follow those instructions. By following those instructions, you won't have to change any code on your site and you don't have to read on.

    Screenshot of Global site tag for Google Analytics 4.0

  5. In your WordPress Dashboard, click on "Divi" -> "Theme options" in the sidebar.

  6. Click on "Integration". Go to the "Add code to the < head > of your blog" box.

    If you are going to remove the old Analytics code, find it and delete it (assuming you added the old Analytics code through here too, if not, remove it from the plugin you used - you might have used an SEO plugin or a specific plugin, or even a child theme). If you don't remove it, it's not a big deal, you'll just be tracking both properties.

    Now, paste the newly copied code.

    Screenshot of how to upgrade to Google Analytics 4.0 inside the WordPress Dashboard with Divi Theme

  7. Scroll to the bottom and click "Save Changes".

I hope this was helpful in demonstrating how to add Google Analytics 4.0 to your Divi WordPress site.

Keep in mind, you might have a plugin that you used to add the Google Analytics code in the past, but I don't feel it is necessary when Divi has a spot already to add the Analytics code.

Want to learn how to code and make money online? Check out CodingPhase (referral link)