A
A
and7ey2014-09-17 20:54:41
Yandex.Metrica
and7ey, 2014-09-17 20:54:41

How to use Yandex.Metrica Form Analytics with an AJAX form?

According to the Yandex.Metrica documentation , the form should be sent on the submit event. I have the following code to submit the form:

<form class="form-horizontal" role="form" id="utsDetails">
...
<button type="button" id="calc" name="calc">Calculate</button>
</form>

<script type="text/javascript">
   $("#calc").click(function() {
      $.ajax({
        type: 'POST',
        dataType: 'json',
        data: {
           // all utsDetails form fields are there
        },          
        beforeSend: function(){
           // ...
        }
      })
      .done(function(data, textStatus, jqXHR) {
          // ...
      });

How can I convert this code so that Yandex.Metrica tracks this form? Would using $("#utsDetails").submit(function()... help ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question