Trying to add google ad onclick to wordpress and Divi buttons and header link

As you mentioned in the comment, if you have the ability to add ID value(s) to the elements, or you can try using css selector. choose what’s best for you. then do as follows..

in your custom js file, add this,

(if you don’t have your own custom js file, you can add one, append following into your theme’s functions.php file)

function add_custom_scripts() {
wp_enqueue_script( 'my-custom-script', get_template_directory_uri() . '/js/mycustom.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'add_custom_scripts' );

in your js file,

jQuery(document).ready(function() {

var gButton = jQuery("#your-element-id");
var url = "http://example.com/your-link";

gButton.on("click", function(){ gtag_report_conversion(url); });

});

add every element you want to track in there and call the gtag_report_conversion(url) as I mentioned. That’s all.

I assume you’ve already set up necessary steps, installed the global site tag and Event snippet code to necessary pages.