Step-by-Step: Add GA4 Tracking to Divi Theme
17 September 2025

Step-by-Step: Add GA4 Tracking to Divi Theme

Google Analytics is a powerful tool that helps you understand your website’s audience and how they interact with your site. With the shift from Universal Analytics to Google Analytics 4 (GA4), it’s essential to ensure your tracking setup is up to date. If you’re using the Divi Theme by Elegant Themes, adding GA4 can be done smoothly with just a few steps. In this guide, we’ll walk you through the entire process of integrating GA4 with Divi, from creating your tracking ID to verifying it’s working correctly.

Why Google Analytics 4 and Why Now?

Google Analytics 4 is the latest iteration of Google’s web analytics platform. Unlike Universal Analytics, GA4 provides enhanced measurement features, stronger privacy controls, and the ability to track users across multiple platforms and devices. As of July 2023, GA4 has become the default platform for new properties, so if you’re still relying on the older version, it’s time to upgrade.

Whether you’re a seasoned marketer or a new business owner, getting familiar with GA4 will ensure you’re collecting the most accurate and actionable data. Now, let’s move on to integrating it with your Divi-powered website.

Step 1: Create a Google Analytics 4 Property

If you haven’t already set up a GA4 property, you’ll need to do that first. Here’s how:

  1. Go to https://analytics.google.com/ and sign in with your Google account.
  2. Click on “Admin” in the bottom left corner of the dashboard.
  3. Under “Property,” click “+ Create Property.”
  4. Enter your website details, such as name, time zone, and currency.
  5. Click “Next,” then fill in the relevant business information.
  6. Select “Web” as the platform for data collection in the data stream settings.

Once done, you’ll be provided with a Measurement ID that looks like G-XXXXXXXXXX. Keep this ID handy; you’ll need it soon.

Step 2: Add GA4 Tracking to Your Divi Theme

Now that you have your GA4 Measurement ID, it’s time to add the tracking code to your Divi website. The Divi Theme makes this relatively straightforward.

Option 1: Using the Divi Theme Options

This is the recommended and simplest method to add GA4 to your Divi site:

  1. Log in to your WordPress dashboard.
  2. Navigate to “Divi” > “Theme Options.”
  3. Click on the “Integration” tab.
  4. In the box labeled “Add code to the <head> of your blog,” paste the GA4 global site tag, which looks like this:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>

Note: Replace G-XXXXXXXXXX with your actual Measurement ID.

Click “Save Changes” at the bottom of the page, and you’re all set.

Option 2: Using a Child Theme or Custom Plugin

If you want to keep your tracking codes separate or have a custom setup, you can add the GA4 code manually using a child theme or a custom plugin:

  1. Use an FTP client or a file manager plugin to access your WordPress files.
  2. Navigate to your child theme’s “header.php” file.
  3. Paste the GA4 tracking script right before the closing </head> tag.

This method is more advanced and is generally only recommended for developers or those who are comfortable editing theme files.

Step 3: Test That Everything is Working

After installing the tracking code, you’ll want to verify that it’s functioning correctly. Luckily, several methods can help you do this.

Use Real-Time Reports in GA4

Go back to your GA4 dashboard and navigate to the “Realtime” section. Visit your site in a separate browser tab or device and check if your visit is recorded. If you see activity, the script is working.

Use Google Tag Assistant

This browser extension helps you troubleshoot issues with your tags. Simply install it, go to your site, and it will show you whether your GA4 tag is installed and firing correctly.

Alternatively, you can use Google Tag Assistant (Web Interface) to debug your site online.

Step 4: Customize Your Tracking (Optional)

GA4 offers many options to track custom events, such as button clicks, scrolls, video engagement, and more. Here’s a quick overview:

  • Enhanced Measurement: Enabled by default in GA4, it tracks user interactions such as scrolls, clicks on outbound links, internal site searches, video engagement, and file downloads.
  • Custom Events: If you have specific user actions you want to track, like contact form submissions or product clicks, you can set up custom events in GA4 or use Google Tag Manager.

Integrating GA4 with Google Tag Manager (GTM) gives you even more flexibility and control. GTM allows you to manage multiple scripts from a single interface without editing your site’s code repeatedly.

Step 5: Monitor Reports and Set Goals

Once GA4 is installed and data starts coming in, you can set up reports and conversion goals directly in your GA4 dashboard.

Some key areas to monitor:

  • User Acquisition: Where are your visitors coming from?
  • Engagement Rate and Average Engagement Time: How interested are users in your content?
  • Events: What actions are users taking on your website?
  • Conversions: Are your business goals being met?

This level of granularity allows you to make informed decisions about your site’s layout, marketing strategies, and content direction.

Troubleshooting Tips

  • Double-check your Measurement ID: Typos happen—make sure the ID matches exactly.
  • Avoid caching conflicts: Clear your site cache and browser cache after adding the GA4 code. Caching plugins can delay script updates.
  • Use an Incognito window: To test your site without browser extensions interfering.

If the real-time report doesn’t show activity after 24 hours, consider removing and re-adding the code or consult Google’s Analytics Help Center.

Wrapping Up

Adding GA4 tracking to a Divi Theme website is not only essential for data-driven decision making, it’s also relatively easy to set up. By following the steps in this guide, you’ll ensure that your analytics platform is ready for the future—and so is your business. Remember, the insights gained from properly configured analytics can be a game-changer in how effectively your website performs.

Once installed, spend time exploring GA4’s new features, build reports that align with your goals, and continuously refine your tracking to best reflect user behavior. This will empower you to create a conversion-focused, user-friendly website experience.

Leave a Reply

Your email address will not be published. Required fields are marked *