K
K
kepkame2019-02-09 11:18:25
JavaScript
kepkame, 2019-02-09 11:18:25

Why might the Google Analytics goal fail in jQuery code?

Passing form field values ​​to pnp works through a jQuery script, it passes the field values ​​to a php file, then updates the value of all form fields and pops up a successful submission notification.
In jQuery, immediately after sending the field values ​​to php, the Yandex Metrics and Google Analytics goals must also be fulfilled.

The TARGET goal in Yandex Metrica is marked as completed, but Google Analytics does not see the goal being completed.
Tell me why Analytics can not see the achievement of the goal?

jQuery script

$(document).ready(function() {
  //E-mail Ajax Send
  $("form").submit(function() {
  var th = $(this);
    $.ajax({
      type: "POST",
      url: "php/mail.php",
      data: th.serialize(),
      success: function(data) {
        th.parent().find(' input[type=text], input[type=tel], input[type=email], textarea').val('');
        ym(XXXXXXXX, 'reachGoal', 'TARGET');
        ga('send', 'event', 'submit', 'TARGET');
      }
    }).done(function() {
    $(".form_info").addClass("form-info-open");
      setTimeout(function() {
        // Done Functions
        th.trigger("reset");
      }, 1000);
      setTimeout(function(){
                $('.form_info').removeClass('form-info-open');
            }, 10000)
    });
    return false;
  });
});

All form code https://jsfiddle.net/yjxgn7dz/1/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2019-02-09
@dimonchik2013

trace requests to the GA server, fix, repeat (iterate)
the same - in parallel (on another account) without jQuery

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question