With the shift to Google Analytics 4 (GA4), marketers and web developers are looking for smarter ways to integrate event tracking and manage user consent effectively—especially with content management systems like WordPress and page builders like Divi. Compared to Universal Analytics, GA4 provides a more flexible event-based model for tracking user interactions, but setting it up within Divi, particularly in compliance with Consent Mode v2, can be daunting without guidance.
This article provides a step-by-step approach to adding GA4 to a Divi-powered website, implementing event tracking, and respecting users’ privacy preferences using Google’s Consent Mode v2.
Understanding GA4 in a Divi Environment
Divi is one of the most popular WordPress themes and visual builders, but it doesn’t provide a native way to implement advanced analytics like GA4 out of the box. Fortunately, with some simple configuration, you can turn your Divi site into a data-collection powerhouse—one that’s both privacy-conscious and easy to manage.
GA4 emphasizes events over traditional pageviews, offering a more dynamic way to measure user engagement. Whether your visitors click a call-to-action button, scroll to a page’s bottom, or download a file, GA4 lets you track it all. Divi, known for its builder modules and customization capability, works well when you know where to integrate the tracking code and how to configure it intelligently.
Why Consent Mode v2 Matters
Google’s Consent Mode v2 addresses compliance with major privacy regulations such as the EU’s GDPR and California’s CCPA. Consent Mode controls how Google tags behave before and after a user consents. With Consent v2, you can:
- Ensure no data is sent to Google Analytics until explicit user consent is given.
- Respect user choices on ad and analytics storage.
- Enhance transparency and reduce legal risks.
GA4 and Consent Mode v2 can work synergistically to ensure ethical tracking practices—and as user expectations grow, it’s not only best practice but also a competitive differentiator.
Step-by-Step: How to Add GA4 to Divi
1. Set Up GA4
If you haven’t already, create a GA4 property in your Google Analytics account. Once complete, copy your “Measurement ID,” which looks like G-XXXXXXXXX
.
2. Install Google Tag Manager (GTM) on Divi
Though you could paste the GA4 global site tag directly into Divi, using Google Tag Manager provides more flexibility, especially when configuring event tracking and consent mode.
- Create a GTM container in your Google Tag Manager account.
- Copy the GTM code snippets (both
<head>
and<body>
). - In your WordPress dashboard, go to Divi > Theme Options > Integration.
- Paste the
<head>
code into “Add code to the <head> of your blog.” - Paste the
<body>
code right after “Add code to the <body> (beginning of the body tag).”
Save your changes, and GTM will now be active on your site.

3. Add the GA4 Configuration Tag
In your GTM dashboard:
- Create a new tag and choose “Google Analytics: GA4 Configuration.”
- Paste your GA4 Measurement ID into the designated field.
- Set the trigger to “All Pages.”
- Save and publish the tag.
This tag will load GA4 on every page of your site. Now that you have basic traffic measurement in place, let’s proceed to event tracking.
Event Tracking in Divi
GA4 provides options to either track automatic events (like page_views and clicks) or create custom events with GTM. With Divi’s intuitive builder grid and CSS classes, identifying elements to track is relatively easy.
4. Identify Elements on Divi to Track
For example, suppose you want to track clicks on a “Get Quote” button. Using Divi’s module settings:
- Edit the button module you want to track.
- Go to Advanced > CSS ID & Classes.
- Add a unique CSS class like
get-quote-button
.
5. Create a Custom Event Tag in GTM
Back in GTM:
- Click “Triggers” and create a new “Click – All Elements” trigger.
- Choose “Some Clicks” and set the condition to
Click Classes contains get-quote-button
. - Then create a new GA4 “Event” tag.
- Name the event (e.g.,
get_quote_click
) and attach the trigger you just created. - Save and publish the tag.
This lets you track the success of CTAs and refine the effectiveness of landing pages over time.

Implementing Google Consent Mode v2
The updated Consent Mode v2 introduces two new parameters: ad_user_data
and ad_personalization
in addition to analytics_storage
and ads_storage
. You can implement these via GTM with a Consent Initialization tag and a Consent Management Platform (CMP) such as Cookiebot or Complianz.
Recommended Setup:
To configure Consent Mode v2 on a Divi site:
- Install a CMP plugin compatible with GTM, like Cookiebot.
- Follow your CMP’s integration guide to enable Consent Mode automatically.
- In GTM, modify your GA4 tag to trigger only after consent is granted.
This way, analytics-related cookies only load if the user agrees, staying compliant with European and Californian regulations.
Testing Your Setup
Once implemented, testing is crucial. Use the following tools to verify GA4 integration:
- Google Tag Assistant – Review tag firing and identify misfires.
- GA4 DebugView – See real-time data and event monitoring.
- Browser DevTools – Inspect DOM elements and consent state.
Be sure to test consent revocation, cookie-blocking, and custom events from various user scenarios, including first-time visitors and returning ones.
Tips for Optimization
To take your integration even further and make sure you’re collecting meaningful data, consider these tips:
- Use meaningful event names and parameters to make reports easier to analyze.
- Leverage GA4’s custom dimensions to track user types, content categories, or intent.
- Integrate with Google Ads for deeper retargeting and campaign analytics tied to consent.
- Stay updated on privacy laws and revise your implementation every 6–12 months.
Conclusion
Integrating GA4 with Divi opens up a world of possibilities—not just in terms of data granularity, but also in building a privacy-first website that respects visitor choices. By using Google Tag Manager and Consent Mode v2, you’re not only gaining deep insights into user behavior but also adhering to the growing demand for transparency and control in digital experiences.
With the right tools and strategy, turning your Divi site into a modern, compliant analytics hub is entirely within reach.