javascripthtmlwordpressgtag.jswpforms

gtag_report_conversion not counting in ADS with wpforms


My google ads is not counting conversions.

I am using this code, I am sure that this functions is been called, because if a put a alert in the gtag_report_conversion, the page show the alert.

But I have no ideia why the ads is not counting the conversions.

I have talked with two gtag teams, but neither of they now how to fix.

  var callback = function () {
    if (typeof(url) != 'undefined') {
      //window.location = url;
    }
  };
  gtag('event', 'conversion', {
      'send_to': 'AW-*****/*******',
      'event_callback': callback
  });
  return false;
}
var el = document.getElementById('wpforms-submit-322');
if (el){
    el.addEventListener("click", gtag_report_conversion);  
}

UPDATE 16/11/2021:

I changed the code to and worked for 1 day, than stoped again:

jQuery('#wpforms-submit-322').attr('type', 'button');
jQuery('#wpforms-submit-322').on('click', function(e) {
    e.preventDefault();
    const $form = jQuery('#wpforms-form-322');
    if ($form.valid()) {
        gtag('event', 'conversion', {
            'send_to': '*******/*******',
            'event_callback': function() {
                console.log('enviado.');
                jQuery('#wpforms-form-322').trigger('submit');
            }
        });
    }
});

Solution: Problem with ads, just create a new conversion tag and use the new one.


Solution

  • Solution: Problem with ads, just create a new conversion tag and use the new one.