How to setup Google Analytics event tracking in Divi?

Hi Guys,

This tutorial can give you quick easy fix for setting up Google Analytics event tracking in Divi Contact form. Before going forward, I assumed your website is well  set up with ga code and it’s working fine.

Here logic is to use jQuery(Javascript library) to track form submit an event and keeping validation to ensure there is no error. This solution may not cover all the cases but cover almost 99% use cases.

Kindly add this js script in your custom .js file or can use WP add_inline_script().

		let dcHasError = true;
		setTimeout(function() { // now wait 1000 milliseconds...
          $('.et_pb_contact_form input').each( function() {
          	if( false === $(this).hasClass('.et_contact_error') ) {
          		dcHasError = false;
          		return false;
          if( true === dcHasError) {
          	ga('send', {
    		  hitType: 'event',
    		  eventCategory: 'event category name',
    		  eventAction: 'Form Submit',
    		  eventLabel: 'event category name'

Hope this helps to anyone struggling to tracking Divi contact form.



Join the Conversation


      1. Thanks for the code. I can do the form validation just fine with it, but for some reason the event is not registering in Google Analytics. I tried another kind of Jquery code for contact forms in divi so i know the events track just fine. That code however doesnt do validation and registers a submission regardless of whether form was submitted or not.

        Any help would be much appreciated


Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: