Google Analytics 4 (GA4) is the future of website tracking. If you’re using the Divi theme for your WordPress site, you’re in luck! Integrating GA4 is a simple process, and we’ll show you exactly how to do it. Plus, we’ll dive a little into Google’s new Consent Mode v2. Don’t worry — we’ll keep it fun, light, and easy. 🍰
🚀 Why Should You Care About GA4?
If you’re still using Universal Analytics, you’re kind of stuck in the past. Google has officially sunset Universal Analytics, and GA4 is now the default. That means:
- Better data tracking
- Event-based measurement (no more pageviews only!)
- Privacy-friendly options
- Cool new reports
GA4 doesn’t just track who visits your site. It tells you what people are doing, when they do it, and helps you improve their experience. Sounds awesome, right?
🛠️ Installing GA4 on Divi — The Quick Way
Let’s get your Divi website connected to GA4 in just a few minutes. Here’s what you need:
Step 1: Get Your GA4 Code
Log in to your Google Analytics account. From the left menu, go to Admin → Data Streams → choose your site → copy the Measurement ID. It starts with “G-” and looks like G-XXXXXXX.
Step 2: Add Code to Divi
Now head to your WordPress dashboard.
- Go to Divi → Theme Options.
- Click on the Integration tab.
- Find the box labeled “Add code to the <head> of your blog”.
- Paste this script:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-XXXXXXX'); </script>
Don’t forget to replace G-XXXXXXX with your real Measurement ID!
Click Save. Done! 🎉 You’ve installed GA4.

✅ But Wait! What About Consent?
If you’re in the EU (or dealing with EU visitors), the law says you need cookie consent before tracking. That’s where Consent Mode v2 steps in.
What is Consent Mode v2?
Google created Consent Mode to help websites stay compliant with GDPR while still collecting meaningful data. Consent Mode v2 builds on that with even more control.
In simple terms, it:
- Waits for users to give permission (via a cookie popup)
- Then tells Google Analytics what the user allowed
- Adjusts how data is collected based on that consent
With Consent Mode v2, GA4 can still do a decent job even if a user says “No cookies please!” Smart, right?
📋 Setting Up Consent Mode in Divi
Consent Mode doesn’t come built-in with Divi. But you can set it up pretty easily with a cookie plugin. Our top picks are:
- Cookiebot — Free + easy to use
- Complianz — Packed with features
- CookieYes — Stylish and flexible
We’ll explain how to use Cookiebot to enable Consent Mode. The steps are similar for other tools too.
Step 1: Sign Up for Cookiebot
Go to cookiebot.com and create an account. Add your domain.
Step 2: Get the Script
After setup, Cookiebot will give you a script. It looks kind of like this:
<script id="Cookiebot" src="https://consent.cookiebot.com/uc.js" data-cbid="YOUR_ID_HERE" type="text/javascript" async></script>
Just like before, copy that script.
Step 3: Add to Divi
Go back to Divi → Theme Options → Integration. In the same “Add code to head” box, paste the Cookiebot script above your GA4 script. Save it. Done!
Bonus: Tell GA4 to Respect Consent
Add a small change to your GA4 script to let it work with Consent Mode:
gtag('consent', 'default', { 'ad_storage': 'denied', 'analytics_storage': 'denied' });
So your GA4 code now looks like this:
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('consent', 'default', { 'ad_storage': 'denied', 'analytics_storage': 'denied' }); gtag('js', new Date()); gtag('config', 'G-XXXXXXX'); </script>
This tells GA4 to wait. It won’t start tracking unless Cookiebot says it’s okay.

📈 Test It All Out
Let’s make sure it’s working!
1. Use Tag Assistant
Install the Google Tag Assistant extension. Go to your website and open the Tag Assistant. You should see GA4 firing when consent is given.
2. Check Google Analytics
Open your GA4 dashboard. Click “Real-time” and visit your site. If everything’s set up right, you’ll see yourself pop up in your active users!
3. Try Without Giving Consent
Open your website in an incognito window. Do not accept cookies. Visit your GA4 Real-time view again. No activity should show until you click “Accept.”
🎨 Tips to Make It Even Better
- Customize the Consent Popup: Match it with your brand colors
- Send Custom Events: GA4 lets you track button clicks, scrolls, and more
- Use Google Tag Manager: Advanced users can manage multiple scripts easier

🎉 Final Thoughts
Now your Divi website is running the latest and greatest: GA4 + Consent Mode v2. It’s modern, privacy-respecting, and smarter than ever.
Get used to checking your new dashboards. See what’s working. Improve pages with high drop-offs. Celebrate when people click that “Buy Now” button!
With a few small tweaks, you’ve taken a big leap forward. 🚀
Happy tracking, Divi Jedi!