A
A
Adilet Zhuman2018-08-24 14:41:06
JavaScript
Adilet Zhuman, 2018-08-24 14:41:06

How to send an event to google analytics via js?

The point is this. I want to send statistics from submitting a form.
on js wrote sending on the submit event.

$(".lets_work_form").submit(function() {
    ga('send', 'event', {
    eventCategory: 'form',
    eventAction: 'submit'
  });
   });

".lets_work_form" is the class of the form itself.
There is no error in the console. But for some reason the data is not sent to Google Analytics! how to solve this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Andreichenko, 2018-08-24
@MB116

Show the site, your submit code is more like using the new gtag.
Change from gtag:

Было:
ga('send', 'event', 'form', 'submit');

Стало:
gtag('event', 'submitForm', { 'event_category': 'form', 'event_action': 'submit', });

submitForm - can be arbitrary.

M
Michael, 2018-08-24
@FFxSquall

At you the data does not have time to otrpavitsya. You need to wait for the data to be sent to Google, and then submit the form. More details here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question